From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 650 invoked by alias); 21 Jun 2016 16:09:20 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38737 Received: (qmail 1177 invoked from network); 21 Jun 2016 16:09:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-AuditID: cbfec7f5-f792a6d000001302-c4-576966aa26cc Date: Tue, 21 Jun 2016 17:09:11 +0100 From: Peter Stephenson To: Zsh Hackers' List Subject: Re: PATCH: zcalc RPN part 2 Message-id: <20160621170911.526507d8@pwslap01u.europe.root.pri> In-reply-to: <20160621162828.72371587@pwslap01u.europe.root.pri> References: <20160621162828.72371587@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHLMWRmVeSWpSXmKPExsVy+t/xy7qr0jLDDabN17I42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGa9WyBTMFaloetTD1sC4X6CLkZNDQsBE4sC/x0wQtpjEhXvr 2boYuTiEBJYySqzYfpIJwpnBJPHx8i1WkCohgXOMEl+u8EIkzjJKTLm2jBEkwSKgKnFs121m EJtNwFBi6qbZQHEODhEBbYn2j2IgYWEBFYlrn5pZQGxeAXuJ1udLwWxOAQeJS73fmSHm20u0 zHkGdhG/gL7E1b+foK6zl5h55QwjRK+gxI/J98B6mQW0JDZva2KFsOUlNq95CzVHXeLG3d3s ExiFZyFpmYWkZRaSlgWMzKsYRVNLkwuKk9JzjfSKE3OLS/PS9ZLzczcxQkL56w7GpcesDjEK cDAq8fBWGGaEC7EmlhVX5h5ilOBgVhLh3ZuQGS7Em5JYWZValB9fVJqTWnyIUZqDRUmcd+au 9yFCAumJJanZqakFqUUwWSYOTqkGxg3W/m32ZyWZbIqSKz2S5+vffVKw7s+6N3ud+Navl50p r5798OB08xBtyRqWdZpzdMxPG+xXVr7tJXbD3rflEoNCxas7Sm3cbaf4LscuVXabarHgj3vg 6TeKVuyPrhuuvfQqRG2rRNClhv/hHx89P2DuHvw66szB///OhV5e6l04SfsP67RP55VYijMS DbWYi4oTASH0HGthAgAA On Tue, 21 Jun 2016 16:28:28 +0100 Peter Stephenson 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. )