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

Re: Partial implementation of "nameref", sort of.



Bart wrote:
> This is incomplete, but presented for consideration of how to proceed
> with it.

This is storing the string reference to the name, right? That is also
what the somewhat more complete implementation from back in 15058 did
except that also recorded the local level so a nameref to a local
variable from a calling function would work. I could rebase that patch
if it would be useful? I've also got a file of test cases from the time.

At the time, my understanding of the consensus was that an
implementation needed to instead use a pointer as the internal
representation of the reference (along with either reference counting or
garbage collection). Certain features in the ksh implementation are hard
to implement otherwise (e.g. reference to an unset variable). For that
to work, the parameter code (at least as it then stood) needed a certain
amount of refactoring. I think certain typeset options result(ed) in the
parameter being destroyed and created anew.

It's a more useful feature in Ksh which has lexically scoped local
variables. Ksh special cases nameref ref=$1 to take the referenced
parameter from the parent scope which seems quite ugly to me. I'd prefer
something more explicit like Tcl's uplevel command.

Oliver



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