Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] declarednull: rename DECLARED to NULL
- X-seq: zsh-workers 47808
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] declarednull: rename DECLARED to NULL
- Date: Thu, 7 Jan 2021 15:48:18 +0000
- Archived-at: <https://zsh.org/workers/47808>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-01/20210107154818.GB25249%40tarpaulin.shahaf.local2>
- In-reply-to: <CAH+w=7a5xzztvJ9hRB-2-LyzyZFx74Pfy5z8cJu01=hOh_AHQw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <20201228221342.136199-1-felipe.contreras@gmail.com> <CAH+w=7aHddgDB9jbKoL2pceNwPM48pF6+V3oiHzd8versYVW7w@mail.gmail.com> <CAMP44s2v4dJJe8XhGfzzvsANMiT25COreKEhuqF3VgEfqSZ4Fg@mail.gmail.com> <CAH+w=7ZL0KGcd8b4mmRhMSPuX-bEgMZi5XG7G37vLo1m87GUAg@mail.gmail.com> <20210104061718.GB14783@tarpaulin.shahaf.local2> <CAH+w=7ZX8ddgLH3DdsrCg6pgxY8KbRo1nqF5qLxZ2HL0JtcWNw@mail.gmail.com> <4e9d7283-94fa-4862-ab04-8c3294f3876c@www.fastmail.com> <CAH+w=7a5xzztvJ9hRB-2-LyzyZFx74Pfy5z8cJu01=hOh_AHQw@mail.gmail.com>
Bart Schaefer wrote on Wed, Jan 06, 2021 at 09:33:49 -0800:
> On Wed, Jan 6, 2021 at 8:02 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >
> > Bart Schaefer wrote on Mon, 04 Jan 2021 21:57 +00:00:
> > > So the "bits that need to be named" are:
> > > 1) the bit representing "remember that this was declared but no value
> > > was assigned"
> > > 2) the combination of that with PM_UNSET that represents "functionally
> > > behaves like NULL"
> >
> > To be clear, (2) would generally be used as testing whether _either_
> > PM_UNSET or the bit from #1 is set, right?
>
> Most often it's used for changing the value of both bits at once, not
> testing. The bits are almost always tested independently.
*nod*
> > How about, for #1, PM_BEEN_ASSIGNED or PM_INITIALIZED?
>
> The latter was already rejected. Both of these arguably describe the
> opposite of the actual state, that is, PM_HAS_NOT_BEEN_ASSIGNED would
> be more accurate ... but Felipe has essentially argued that after
> "unset foo" the variable still has not been assigned, so why clear a
> bit with that name?
After «unset», PM_UNSET would be set, and I don't immediately see why bit #1
should be tested at all if if PM_UNSET is set. If the «unset» is followed by
an assignment and/or (re-)declaration, the value of bit #1 can then be set
properly, and PM_UNSET cleared. Makes sense?
> PM_DECLARED_BUT_NEITHER_ASSIGNED_NOR_UNSET is just too verbose, and
> shortening it to just the first word got us into this discussion in
> the first place.
>
> > As to the combination, my first inclination would have been to leave it
> > unnamed so that it's obvious PM_UNSET is being inspected, but if the
> > combination merits being named, then perhaps PM_HAS_VALUE(pm).
>
> The reason for doing it the way I did is because (I presumed) most
> cases would never examine bit #1 because they are already examining
> PM_UNSET by itself.
>
> PM_HAS_VALUE(pm) is actually also backwards. It would usually be
> PM_HAS_NO_VALUE(pm). But there's actually exactly one such test.
So long as we don't have «!PM_HAS_NO_VALUE(pm)» ☺
Messages sorted by:
Reverse Date,
Date,
Thread,
Author