From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: PATCH: zcalc RPN part 2
Date: Tue, 21 Jun 2016 17:09:11 +0100 [thread overview]
Message-ID: <20160621170911.526507d8@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20160621162828.72371587@pwslap01u.europe.root.pri>
On Tue, 21 Jun 2016 16:28:28 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> Next project is to do something about
>
> # TODO: make local variables that shouldn't be visible in expressions
> # begin with _.
>
> which has reached the pain threshold. I won't bother posting the
> diff except perhaps for the documentation.
Here is documentation for variables after that change.
pws
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index c875c95..53ae96d 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -3764,8 +3764,14 @@ first few positional parameters. A visual indication of this is given when
the calculator starts.
The constants tt(PI) (3.14159...) and tt(E) (2.71828...) are provided.
-Parameter assignment is possible, but note that all parameters will be put
-into the global namespace.
+Parameter assignment is possible, but note that all parameters will be
+put into the global namespace unless the tt(:local) special command is
+used. The function creates local variables whose names start with
+tt(_), so users should avoid doing so. The variables tt(ans) (the last
+answer) and tt(stack) (the stack in RPN mode) may be referred to
+directly; tt(stack) is an array but elements of it are numeric. Various
+other special variables are used locally with their standard meaning,
+for example tt(compcontext), tt(match), tt(mbegin), tt(mend), tt(psvar).
The output base can be initialised by passing the option `tt(-#)var(base)',
for example `tt(zcalc -#16)' (the `tt(#)' may have to be quoted, depending
@@ -3831,6 +3837,10 @@ stored locally in the first element of the array tt(psvar), which can be
referred to in tt(ZCALCPROMPT) as `tt(%1v)'. The default prompt is
`tt(%1v> )'.
+The variable tt(ZCALC_ACTIVE) is set within the function and can
+be tested by nested functions; it has the value tt(rpn) if RPN mode is
+active, else 1.
+
A few special commands are available; these are introduced by a colon.
For backward compatibility, the colon may be omitted for certain
commands. Completion is available if tt(compinit) has been run.
@@ -3870,8 +3880,7 @@ is executed in the context of the function, i.e. with local variables.
Space is optional after tt(:!).
)
item(tt(:local) var(arg) ...)(
-Declare variables local to the function. Note that certain variables
-are used by the function for its own purposes. Other variables
+Declare variables local to the function. Other variables
may be used, too, but they will be taken from or put into the global
scope.
)
prev parent reply other threads:[~2016-06-21 16:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-21 15:28 Peter Stephenson
2016-06-21 16:09 ` Peter Stephenson [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=20160621170911.526507d8@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-workers@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).