Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: 3.1.5 - sample associative array implementation
- X-seq: zsh-workers 4628
- From: Timothy Writer <Tim.Writer@xxxxxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: PATCH: 3.1.5 - sample associative array implementation
- Date: 13 Nov 1998 20:55:53 -0500
- Cc: zsh-workers@xxxxxxxxxxxxxxx
- In-reply-to: "Bart Schaefer"'s message of "Thu, 12 Nov 1998 17:32:01 -0800"
- References: <9811111358.AA51361@xxxxxxxxxxxxxxxxx> <vb1znanvcm.fsf@xxxxxxxxxxxxxxx> <m3iugmj8y8.fsf@xxxxxxxxxxxxxxxxx> <981111125236.ZM3587@xxxxxxxxxxxxxxxxxxxxxxx> <m3d86t7235.fsf@xxxxxxxxxxxxxxxxx> <981112012358.ZM9722@xxxxxxxxxxxxxxxxxxxxxxx> <m367ck7907.fsf@xxxxxxxxxxxxxxxxx> <981112173201.ZM13829@xxxxxxxxxxxxxxxxxxxxxxx>
"Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx> writes:
> On Nov 12, 7:04pm, Timothy Writer wrote:
> > Subject: Re: PATCH: 3.1.5 - sample associative array implementation
> [Referring to ksh93]
> >
> > typeset -A foo
> > foo[bar]=baz
> > echo ${!foo}
> >
> > just prints "foo". Makes sense because foo is not a nameref.
>
> That's not what I would have expected; I would have expected it to either
> (a) behave the same as ${foo} [which means what, when foo is an associative
> array?] or (b) print nothing, because there's no variable to which the value
> of foo can possibly refer. Printing its own *name* like that isn't sensible
> to me.
In ksh93, $arrayname is a synonym for ${arrayname[0]}. This appears to be
true for indexed arrays _and_ associative arrays.
If you think of nameref as being like a symbolic link and ${!foo} as being
like lstat(), it makes perfect sense (at least to my twisted mind) that
${!foo} is just "foo" for ordinary (non nameref) variables.
--
Tim Writer Tim.Writer@xxxxxxxxxx
FTL Solutions Inc.
Toronto, Ontario, CANADA
Messages sorted by:
Reverse Date,
Date,
Thread,
Author