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

Re: named references



On Jun 28, 10:39am, Peter Stephenson wrote:
> Subject: Re: named references
> 
> I'd be very tempted just to store the name of the object referred to,
> after a bit of sanity checking, and dereference it right at the last
> minute as if with ${(P)...}

The problem with the "at the last minute" approach is that there are a
lot more places where namerefs have to expose the underlying parameter
than just in the parameter substitution code.  If the dereference takes
place too late, it has to be dealt with in multiple places: assignment,
`unset', substitution, etc.

Consider for example:

	typeset -n ref=var
	echo ${(P)ref}

This should, I think, be equivalent to ${(P)var}, which means the
nameref dereference has to happen at a lower level than the current
substitution code.  Then there's the existing problem of `${(P)1}': I'm
concerned that if the dereferencing happens even as late as it did in
Oliver's sample code, we're going to run into that sort of thing in a
lot of other places.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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