Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] declarednull: rename DECLARED to NULL



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