Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] declarednull: rename DECLARED to NULL
- X-seq: zsh-workers 47806
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] declarednull: rename DECLARED to NULL
- Date: Wed, 6 Jan 2021 09:33:49 -0800
- Archived-at: <https://zsh.org/workers/47806>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-01/CAH%2Bw%3D7a5xzztvJ9hRB-2-LyzyZFx74Pfy5z8cJu01%3DhOh_AHQw%40mail.gmail.com>
- In-reply-to: <4e9d7283-94fa-4862-ab04-8c3294f3876c@www.fastmail.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>
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.
> 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?
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author