zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: r/w access to calling function's $@
Date: Tue, 13 May 2014 09:43:22 -0700	[thread overview]
Message-ID: <140513094322.ZM23130@torch.brasslantern.com> (raw)
In-Reply-To: <20140513171321.03294b76@pwslap01u.europe.root.pri>

On May 13,  5:13pm, Peter Stephenson wrote:
}
} Passing back values has always been one of my chief annoyances about
} shell functions, nor do I think generically allowing references to
} higher level parameters is a good idea.  We need something more
} specific that I haven't thought of to do parameter references.
} 
} (While I've been distracting you, Bart will meanwhile have thought
} of a way of doing it.)

No such luck this time.  You can do it with the "trap" command or a
parameter declared "local" if the caller cooperates, but you can't do
it all from inside the called function.

I believe ksh namerefs can reach across scopes this way, but you still
have to declare the nameref in the outer scope, and zsh doesn't have
real namerefs yet in any case.

Of course the "standard" way to do this is to use the $reply array or
the $REPLY scalar, which are semi-reserved names for the purpose.


      parent reply	other threads:[~2014-05-13 16:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 16:01 Roman Neuhauser
2014-05-13 16:13 ` Peter Stephenson
2014-05-13 16:42   ` Roman Neuhauser
2014-05-13 16:58     ` Peter Stephenson
2014-05-13 16:43   ` 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=140513094322.ZM23130@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /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).