bug-bash
[Top][All Lists]
Advanced

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

Re: "local -g" declaration references local var in enclosing scope


From: Chet Ramey
Subject: Re: "local -g" declaration references local var in enclosing scope
Date: Mon, 11 Mar 2024 11:49:13 -0400
User-agent: Mozilla Thunderbird

On 3/10/24 3:55 PM, Zachary Santer wrote:

Relatedly, how would one set attributes on a variable declared in a
calling function? 'readonly' and 'export' can do it for their
respective attributes, but otherwise, I think you just can't.

You can't (you might be able to using nameref tricks I'm not motivated
enough to investigate); that's a consequence of dynamic scoping and
how `declare' works.

`readonly' and `export' just act on variables found using the usual
dynamic scooping rules. You could write loadable builtins `array',
`assoc', and `integer' to do the same for those attributes if you
desired.

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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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