[Top][All Lists]

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

Re: Local variables overriding global constants

From: Chet Ramey
Subject: Re: Local variables overriding global constants
Date: Thu, 04 Apr 2013 10:20:50 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130307 Thunderbird/17.0.4

Hash: SHA1

On 4/4/13 12:34 AM, Mike Frysinger wrote:

>> Yes, this has come up before.  It's one reason to keep the compromise in
>> place.  But is FOO being readonly in the function where it's declared and
>> not being able to unset it enough rationale to continue to support these
>> semantics?  One problem is the one you point out below.
> if we had an explicit `declare +r`, then it would be OK :)

If you have declare +r, you might as well not have readonly variables
at all.

>>> would it be possible to enable a mode where you had to explicitly
>>> `declare +r` the var ?  being able to "simply" do `local FOO` allows
>>> accidental overriding in sub funcs where the writer might not have even
>>> realized they were clobbering something possibly important.
>> It's an idea, but I don't really like the idea of making declare +r, which
>> is disallowed everywhere else, do something in just this one special
>> context.  Maybe another flag.  I'll have to think on it.
> is there a reason for not just allowing `declare +r` everywhere ?  seems like 
> the proposal fits nicely into the existing system (although you've said 
> you're 
> not terribly happy with said system): you can do `declare -gr` to get perm-
> read only before, or you can do `declare -r` to get read only by default 
> while 
> still allowing sub functions to override if they really want.

The idea, I believe, behind `readonly' is that you want constants.  There's
no reason to even offer the functionality if you can easily make things


- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/


reply via email to

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