[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/
OpenPGP_signature.asc
Description: OpenPGP digital signature
- Re: ${var@A}; hypothetical, related parameter transformations, (continued)
- Re: ${var@A}; hypothetical, related parameter transformations, Zachary Santer, 2024/03/20
- Re: ${var@A}; hypothetical, related parameter transformations, Greg Wooledge, 2024/03/20
- Re: ${var@A}; hypothetical, related parameter transformations, alex xmb sw ratchev, 2024/03/20
- Re: ${var@A}; hypothetical, related parameter transformations, Zachary Santer, 2024/03/20
- Re: ${var@A}; hypothetical, related parameter transformations, Chet Ramey, 2024/03/21
- Re: ${var@A}; hypothetical, related parameter transformations, Chet Ramey, 2024/03/21
- Re: ${var@A}; hypothetical, related parameter transformations, Zachary Santer, 2024/03/24
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Mike Jonkmans, 2024/03/19
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Chet Ramey, 2024/03/19
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Mike Jonkmans, 2024/03/19
- Re: "local -g" declaration references local var in enclosing scope,
Chet Ramey <=
Re: "local -g" declaration references local var in enclosing scope, Lawrence Velázquez, 2024/03/10
Re: "local -g" declaration references local var in enclosing scope, Kerin Millar, 2024/03/11
Re: "local -g" declaration references local var in enclosing scope, Kerin Millar, 2024/03/11
Re: "local -g" declaration references local var in enclosing scope, Adrian Ho, 2024/03/11
Re: "local -g" declaration references local var in enclosing scope, Chet Ramey, 2024/03/11
Re: "local -g" declaration references local var in enclosing scope, Chet Ramey, 2024/03/11
Re: "local -g" declaration references local var in enclosing scope, Kerin Millar, 2024/03/11