zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: "Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru>,
	<zsh-workers@sunsite.auc.dk>
Subject: Re: Parameter aliasing? RE: PATCH: "typeset -m" plays havoc
Date: Mon, 18 Sep 2000 15:45:25 +0000	[thread overview]
Message-ID: <1000918154526.ZM29557@candle.brasslantern.com> (raw)
In-Reply-To: <002a01c0214c$276649e0$21c9ca95@mow.siemens.ru>

On Sep 18, 12:40pm, Andrej Borsenkow wrote:
} Subject: Parameter aliasing? RE: PATCH: "typeset -m" plays havoc
}
} > >     erase_PS1() { typeset PS1 prompt PROMPT }
} 
} The only clean general way to do it is to introduce real aliases
} instead of separate parameters internally referencing the same value.

How about this as an alternate solution:  Along with the shared pointer
for the value of the "tied" parameters, keep track of the locallevel
whenever any one of the parameters is made local.  When unwinding, only
reset the shared pointer if the tracked locallevel is >= the current
locallevel, and in that case also reset the tracked locallevel to one
less than the current locallevel.  That way, all the "tied" parameters
are reset at most once as each function is unwound.

(I note in passing that parameters created with `typeset -T' become un-
tied when either of them is made local, but special tied parameters like
path/PATH do not.)

} [With aliases] first typeset would save original value and two others
} would simply do nothing (well, they would actually print parameters
} value. But there is no real way to avoid it).

I'm not very happy about this idea, particularly if there's no way to
avoid that side-effect.  If it can't be made to work "as if" there are
separate but "tied" parameters, I'd rather keep hunting for another
solution.  It sounds like it has a lot of potential to interact badly
with the PM_HIDE mechanism, too.

Using `typeset -h' is a workaround for the problem, by the way:

    test_PS1() {
	typeset -h prompt PROMPT
	typeset PS1
    }

As to these issues:

} One point to decide is: should 'unset alias' remove parameter itself
} (with all aliases) or just unset current alias?

There's a bigger question than that:  Which name *is* "the parameter
itself" and which are merely aliases?  Or are none of them really the
parameter?

It can't just unset the alias, because the shell has to behave "as if"
the parameter really were unset; e.g., if you unset PROMPT, zsh should
stop printing a top-level prompt, until such time as you assign to one
of PS1, prompt, or PROMPT.  It can't "forget about" the alias, because
`unset PROMPT; PROMPT=foo' has to retain the side-effect of `PS1=foo'.

It's an incompatible change to unset them all when any of them is unset,
though realistically, probably not a change that anyone would notice.

} And if we want user-defined aliases?

If we're going to go that way, we should implement ksh namerefs instead.
(Except I don't know what happens when you assign to a nameref; does it
assign to the referenced variable, or change the name to which the ref
refers?)

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

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


      reply	other threads:[~2000-09-18 15:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-14 15:42 Bart Schaefer
2000-09-14 16:55 ` Andrej Borsenkow
2000-09-14 17:35   ` Bart Schaefer
2000-09-14 18:20     ` Bart Schaefer
2000-09-15 16:35       ` Bart Schaefer
2000-09-15 17:36         ` Andrej Borsenkow
2000-09-15 18:46           ` Bart Schaefer
2000-09-17  3:53             ` PATCH: "typeset +m ..." and "typeset +g -m ..." Bart Schaefer
2000-09-18  8:40           ` Parameter aliasing? RE: PATCH: "typeset -m" plays havoc Andrej Borsenkow
2000-09-18 15:45             ` Bart Schaefer [this message]

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=1000918154526.ZM29557@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=Andrej.Borsenkow@mow.siemens.ru \
    --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).