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

Re: Bug with unset variables



Felipe Contreras wrote on Sat, Nov 21, 2020 at 19:20:56 -0600:
> On Wed, Nov 18, 2020 at 4:45 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> 
> > Do not argue about a person.  Argue about the technical matter at hand.
> 
> That's what I did. The technical matter was being ignored.
> 
> > What are A and B?
> 
> I already explained this multiple times:
> 
> A: unset foo
> B: foo = nil

And in Python, A is «del foo»; B is «foo = None»; and they aren't
equivalent.  Actually, more precisely, Python doesn't even *have* a B,
because Python doesn't have a syntax for declaring a variable without
a value.  (When you write «foo = None», that «None» is not implicitly
provided by the language.)

However, I don't see how any of this is an argument in favour of the
behaviour change you proposed.  Other languages' behaviours be what they
may, they're unlikely to be a good enough reason to break backwards
compatibility.  (For instance, I don't think a proposal to disable null
elision would be accepted, due to backwards compatibility concerns,
regardless of how few other languages do null elision.)

> > Why does the Python example not use «del» as the "unset" operation?
> 
> Because it doesn't do the same thing as unset.
> 
> In shell, this leaves foo declared in a local scope:
> 
>   local foo # declare
>   unset foo # unset
> 
> In Python, this doesn't:
> 
>   foo = None # declare
>   del foo # undeclare
> 
> They are *not* functionally the same thing.

In Python, the "declare" operation would be just «pass», or more
precisely, the removal of any «global foo» declarations… but, again,
unless this Python discussion somehow bears on a proposed change to zsh,
I'm not interested in continuing it.




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