bug-bash
[Top][All Lists]
Advanced

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

Re: Curious case of arithmetic expansion


From: Chet Ramey
Subject: Re: Curious case of arithmetic expansion
Date: Sun, 23 Apr 2017 19:43:43 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.0.1

On 4/23/17 4:25 PM, Florian Mayer wrote:
>> That's not a reasonable expectation.
> Why not? Why is it not reasonable to expect an intuitive
> result from (())? The most intuitive thing, in my opinion,
> would be to use nameref for side effects by default, because in order
> to get a value from an id, (()) already follows namerefs.

The thing that makes that result intuitive for you is your opinion about
how things should work.  That's fine. I don't happen to share your opinion
of what is "intuitive" in this case.

However, it is unreasonable to expect

        var=bar
        (( var=7 ))

to do anything but assign a value to `var'.  Very few people, when asked,
would say that it were more intuitive to cause a variable named `bar' to
spring into existence with the value 7. If you want nameref behavior, you
have to explicitly declare it.


>> It's not indirection, and I am not sure why you show the completely
> I was mentioning that, not because I use „a mental model“ that falsely unifies
> both things, but because I wanted to point out that there exists something
> with a similar behavior.
> 
> And if ${!<varid>} does not portray some kind of indirection, what do you
> call it then?

That is variable indirection. It has superficially similar effects to what
we are discussing, which is arithmetic expansion; however, it has nothing
to do with the behavior of (( )) or $(( )).

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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