Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: type-checking for metafiedness? (was: Re: Cores almost on demand in patcompile())
- X-seq: zsh-workers 39633
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: type-checking for metafiedness? (was: Re: Cores almost on demand in patcompile())
- Date: Fri, 14 Oct 2016 06:36:25 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=LwiWOF56d2cV/ug7 GwQMPadjUiY=; b=kfk1+1z2FcMdysuBIktD84QhM462LNKnU0TUvPS+r21c9Sx+ Ve39UuYSggO3Pf6Txut4FR2GzxRWEJRkiM2+626W4FPQODcBBpO4QpyQ0wJh9Tic wQ65btRGvtyEEsZGWfCAnngG+9VPsa3C4I5OHZcjokivMvcX74UkDwxT2Tw=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=LwiWOF56d2cV/ug 7GwQMPadjUiY=; b=joCIDanpzLJiE6Nija3vgENPXpWrr1XBReEoVbx9TX1bt1k yIL7SVAidz+kdObk7bllVpbV7yzjdUzzlVijEVXIkwBwOwZhn2UnmwDeltuIEEz1 qyihHVX897u4aiHhTQV+w6jZjFs4cOjIOL18ICIgg8Opk13I1afCfNUwFYcg=
- In-reply-to: <CAH+w=7ZArSYVkjcrbAmkeiWsmpiufbj9+DeNhORgKtYEXEkn7Q@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVBEjPJMtV59CrN6LmrDaoGqfa_DZqwo3Y9HK=+0od7ycA@mail.gmail.com> <CAKc7PVCAR2yTJGgdBbvTp=mBC0ZrXcVWW0DE_U26TezSTNdd=A@mail.gmail.com> <CAKc7PVB=485r3nRz_pP3A-k-oq2pOp5qYUK7pE1VEApXb0pR1g@mail.gmail.com> <CAKc7PVDof_GEuoSv7pg8c1=spXfDkWopP5VR8dVHg-bxXVES1g@mail.gmail.com> <CAKc7PVCRtBBVONgiExopYYUv7x4-HN_QEYk-05aoqZihiCRgMw@mail.gmail.com> <CAH+w=7a7jc0Q2=M9aG5mttbazxfsHB-Cz=WwJzCvz_SdnbApRw@mail.gmail.com> <CGME20161011065321eucas1p22afaabbe1f17f26a1b3507619ed1d96f@eucas1p2.samsung.com> <20161011065105.GB16819@fujitsu.shahaf.local2> <20161013112251.329c0dbf@pwslap01u.europe.root.pri> <CAH+w=7ZArSYVkjcrbAmkeiWsmpiufbj9+DeNhORgKtYEXEkn7Q@mail.gmail.com>
Bart Schaefer wrote on Thu, Oct 13, 2016 at 06:46:38 -0700:
> On Thu, Oct 13, 2016 at 3:22 AM, Peter Stephenson
> <p.stephenson@xxxxxxxxxxx> wrote:
> > On Tue, 11 Oct 2016 06:51:05 +0000
> > Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >> Pardon me if this has been discussed before, but why don't we introduce
> >> the type definitions
> >> and start incrementally replacing uses of "char *" with uses of these
> >> types?
> >
> > This probably is a good idea, although the intermediate state where this
> > has been only partly done is likely to be a bit of a mess.
>
> I'd expect to encounter a lot of problems with (char **) arrays where
> every element of the array is (or not) metafied. (Hopefully there
> aren't any that are mixed). As was noted in the discussion of passing
> around lengths of arrays when manipulating array parameters, the older
> code makes a lot of assumptions about pointer arithmetic and s[1][1]
> subscripting and so on.
A 'char **' would become a 'struct metafied_t *', i.e., an array of
structs. This is not equivalent: the array stride of the latter may be
larger than the array stride of the former.¹ However, this would only
be a problem if the code makes assumptions about where elements are
allocated relative to each other, e.g., if the code assumes that
«ary[1] - ary[0] == 1+strlen(ary[0])» or otherwise uses the values of
ary[N] and ary[M] in a single expression.
Does the code make such assumptions?
Cheers,
Daniel
¹ The array stride is sizeof() of the array element's type. The
sizeof() of the struct type may be larger than sizeof() of its member
because structs are allowed to contain padding after the last element.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author