zsh-workers
 help / color / mirror / code / Atom feed
From: Timothy Writer <Tim.Writer@ftlsol.com>
To: "Bart Schaefer" <schaefer@brasslantern.com>
Cc: zsh-workers@math.gatech.edu
Subject: Re: PATCH: 3.1.5 - sample associative array implementation
Date: 12 Nov 1998 03:22:06 -0500	[thread overview]
Message-ID: <m3d86t7235.fsf@ganesh.ftlsol.com> (raw)
In-Reply-To: "Bart Schaefer"'s message of "Wed, 11 Nov 1998 12:52:36 -0800"

"Bart Schaefer" <schaefer@brasslantern.com> writes:

> On Nov 11,  3:00pm, Timothy Writer wrote:
> } Subject: Re: PATCH: 3.1.5 - sample associative array implementation
> }
> } In ksh93 associative arrays are declared using "typeset -A".
> 
> This could easily be mimicked.

Good.

> } They use the
> } same syntax as indexed arrays, e.g. "foo[bar]=baz"; the text within [] is
> } subject to variable expansion and whitespace counts.
> 
> Hrm.  Zsh currently can't handle whitespace inside the [ ]; and I'm not
> sure the paramtab implementation I did will work with keys that aren't
> parsable as "identifier".
> 
> Otherwise this is good.
> 
> How can you (or can you not) assign to multiple elements simultaneously?

I don't know, I don't think you can.  Unfortunately, I'm not a ksh93 expert,
I just paraphrased the above info from the ksh93 reference in "Desktop Korn
Shell Graphical Programming".

> } The following special notation is used to get all keys:
> } 
> }     "${!arrayname[@]}"
> 
> Exactly what about that is the special notation?  The `!'?  Does ksh93

I guess so, "special" is the book's term.

> recognize other special characters in that position?  Is there any way
> to get both the keys and the values in a single expansion?

As far as I can tell, only "!" and (of course) "#" are "special" in that
position.  However, "${!variable}" is also special syntax for name reference
variables, e.g.:

    B=2
    nameref A=B
    print $A		# prints: 2
    print ${!A}		# prints: B

Does zsh have namerefs?

I don't think there's a way to get both keys and values in a single
expression.

-- 
Tim Writer                                              Tim.Writer@ftlsol.com
FTL Solutions Inc.
Toronto, Ontario, CANADA


  reply	other threads:[~1998-11-12  8:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-11  6:44 Bart Schaefer
1998-11-11 13:58 ` Peter Stephenson
1998-11-11 14:43   ` Bruce Stephens
1998-11-11 20:00     ` Timothy Writer
1998-11-11 20:52       ` Bart Schaefer
1998-11-12  8:22         ` Timothy Writer [this message]
1998-11-12  9:23           ` Bart Schaefer
1998-11-13  0:04             ` Timothy Writer
1998-11-13  1:32               ` Bart Schaefer
1998-11-14  1:55                 ` Timothy Writer
1998-11-14  6:41                   ` Bart Schaefer
1998-11-15  8:42                     ` Timothy Writer
1998-11-15 20:03                       ` Bart Schaefer
1998-11-16 19:16                         ` Timothy Writer
1998-11-15 20:47                   ` PATCH: 3.1.5 + associative arrays under ksh emulation Bart Schaefer
1998-11-11 18:16   ` PATCH: 3.1.5 - sample associative array implementation Bart Schaefer
1998-11-13 16:16     ` Associative arrays and memory Peter Stephenson
1998-11-13 17:57       ` Bart Schaefer
1998-11-14 15:26         ` Peter Stephenson
1998-11-14 18:47           ` Bart Schaefer
1998-11-15 15:54             ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3d86t7235.fsf@ganesh.ftlsol.com \
    --to=tim.writer@ftlsol.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).