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

Re: [PATCH] declarednull: rename DECLARED to NULL



Bart Schaefer wrote on Mon, 04 Jan 2021 21:57 +00:00:
> On Sun, Jan 3, 2021 at 10:17 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >
> > Could you summarize the bits that need to be named and the corresponding shell
> > language incantations/semantics?
> 
> There has been a series of threads about this, but to try to summarize:
> 
> In current zsh,
>   typeset -i var
>   typeset -p var
>   print ${var-foo}
> produces the output
>   typeset -i var=0
>   0
⋮
> This disagrees with e.g. bash/ksh, so the proposal is that with
> POSIXBUILTINS set, the same three commands would output
>   typeset -i var
>   foo
> 

Thanks for the summary.

> 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"
> 
> We could of course simply never name #2 and always write out the
> bitwise-OR, but that seems cumbersome.
> 


To be clear, (2) would generally be used as testing whether _either_
PM_UNSET or the bit from #1 is set, right?

How about, for #1, PM_BEEN_ASSIGNED or PM_INITIALIZED?

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).

> As I understand it, the objection to PM_DECLARED for #1 is that the
> name implies that only "unset var" should ever turn that bit off
> again, but the implementation requires that assignment also turns it
> off.  Similar objections of English language semantics conflicting
> with the implementation have been raised to other names I've
> suggested.

*nod*

Cheers,

Daniel




Messages sorted by: Reverse Date, Date, Thread, Author