zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: ${(P)${foo}} (Re: Associative array ordering)
Date: Tue, 2 Feb 1999 09:41:24 -0800	[thread overview]
Message-ID: <990202094124.ZM6976@candle.brasslantern.com> (raw)
In-Reply-To: <199902021658.RAA09882@beta.informatik.hu-berlin.de>

On Feb 2,  5:58pm, Sven Wischnowsky wrote:
} Subject: Re:  Associative array ordering and selective unset (Re: Example 
}
} I wrote:
} 
} > Maybe yet another flag? E.g.: `P' makes the thing after the
} > flags be used as the name of a parameter. So `${(P)foo}' is the same
} > as `$foo', but `${(P)${foo}}' will take the value of `foo' as the name 
} > of a parameter and work on it.
} 
} The patch below does this (it was quite easy).

Well, you got to that before I got around to responding to that particular
tidbit.

The other day someone asked about ksh namerefs in zsh, and I said that with
${(e)...} you didn't really need them.  Here's a case where they would have
been exactly what the doctor ordered; in an appropriate muddle of ksh and
zsh syntax,

	nameref ref=$arg[1]
	echo ${(t)!ref}

which is a whole lot easier on the eyes, it must be admitted.

} With it you can do
} things like the above or `${(P)+${foo}}' to see if the parameter whose 
} name is stored in `foo' is set.

There are actually several ways we can go from here.

We can keep Sven's syntax as is.

We can modify Sven's syntax so that ${(P)foo} is the same as ${(P)${foo}},
and make ${!foo} a synonym for it in ksh compatibility mode.  This is
almost like ksh namerefs except that they don't get their own namespace.

We can make ${!foo} a synonym for ${(P)${foo}} (either in ksh mode or all
the time), leaving ${(P)foo} alone.  I'm not too thrilled about this one.

We can add another hash table to be the nameref namespace, implement the
nameref and `typeset -n' builtins, and make ${(P)foo} [or another letter]
and ${!foo} synonyms where `foo' must be a nameref.  That would deprecate
${(P)${foo}}.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1999-02-02 17:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-02 16:58 Associative array ordering and selective unset (Re: Example function) Sven Wischnowsky
1999-02-02 17:41 ` Bart Schaefer [this message]
1999-02-03  8:02 ${(P)${foo}} (Re: Associative array ordering) Sven Wischnowsky
1999-02-03  8:39 ` Bart Schaefer
1999-02-03  9:55 Sven Wischnowsky
1999-02-03 10:06 Sven Wischnowsky
1999-02-03 10:42 ` 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=990202094124.ZM6976@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).