On 8/28/25 4:07 AM, Martin D Kealey wrote:
On 8/23/25 11:40 PM, Martin D Kealey wrote: > In other languages, binding and assignment are clearly different > operations, where this would clearly NOT be "no different".Oh? int x = 0;If we're talking about C, that's initialisation, not binding. C doesn't have binding in the sense that "declare -n" means.
OK. In terms of the shell nomenclature, reference variables.
> In respect of -l, -u and -r, that's fair comment, so let's set those aside > and focus on binding with -i, where the old behaviour was to fail silently. Why would you ignore -i […] Or are you only considering the -in case, If you are, then make your reasoning explicit.Considering that I'm specifically distinguishing "binding" and "assignment", I thought it was already explicit. Perhaps I should have used a different term rather than "binding", or explained it using an illustration from another language (as above).> Ignoring -i when binding (only applying it when assigning) would seem like > a reasonable backwards-compatible extension,
Non-orthogonal, but I see the point you're making.
Maybe you could give an example of what you mean. $ bar=11**2$ declare -in foo=bar # binds to bar, not to 121 (which it currently fails to do)
Sure. The alternative is to make this a failure (which it always has been, but with the just-added error message). This is compatible with ksh93. ksh93, in fact, does not allow you to create nameref variables with any other attributes. It occurs to me that bash should print a warning when you attempt something like this: declare -n foo=bar declare -i foo since bash disallows that now by ignoring the attempt to add the integer attribute (this is also compatible with ksh93, which does not print a message either).
$ echo "$bar" 11**2 $ echo "$foo" # not magic when reading, though I'm open to changing this too 11**2 $ foo=$foo # numeric evaluation, since foo has -i
I don't really care for the idea of applying the nameref variable's attributes to the referenced variable. It's too much of a special case. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature