bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Global variable modification by nameref chain


From: Dan Douglas
Subject: Re: Global variable modification by nameref chain
Date: Thu, 9 Jun 2016 03:51:56 -0500

On Sat, Jun 4, 2016 at 5:48 PM, Grisha Levit <grishalevit@gmail.com> wrote:
> On May 23, 2016 1:42 PM, "Chet Ramey" <chet.ramey@case.edu> wrote:
>> >     Should the assignment work?  I'm considering changing the
>> > assignments to
>> >     work more like the references.
>> >
>> > I think it would be useful for the assignment to work, as that allows
>> > functions to take variable names as arguments without worrying about
>> > name
>> > collisions.
>>
>> I don't like the fact that variable binding simply ignores nameref loops
>> and treats them the same as the variable not being found.  That's the
>> difference here.
>
> What if (in a function scope) a nameref self-reference were unambiguously
> treated as referring to a variable in the next higher scope, other that
> declare [+-] on an existing ref?

I've thought about this as a workaround but resolving loops that way
will probably lead to problems. Needless to say I prefer doing it the
way I previously described where ref=ref and ref=$1 are distinct.
That's separate from the subject of nameref loops between locals of
the same scope of course.

You can already see some of the eventual problems in ksh if you try to
define a nameref within a compound that points to a local and pass the
compound by reference or copy it between functions using typeset
-c/-m. It's a huge mess of bugs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]