zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-users@zsh.org
Subject: Re: Could someone clarify how math functions work?
Date: Fri, 19 Dec 2014 09:35:51 +0000	[thread overview]
Message-ID: <20141219093551.5a89e4d9@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <54939F50.50102@gmx.com>

On Thu, 18 Dec 2014 22:45:20 -0500
Eric Cook <llua@gmx.com> wrote:
> zsh -c 'add() ( for arg; do (( n += arg )); done; print  n: $n );
> functions -M add; print results: $(( add(1,2,3) ))'
> 
> Outputs:
> n: 6
> results: 3

This is all sorted out --- the ( ... ) runs in a subshell and the value
the math function has access to is the last value in the main shell ---
but I'm scratching my head at how we explain this sort of thing better.
It's just the kind of problem Ray has been banging his head against and
why Kurtis, correctly in my opinion, suggests something other than a
shell for a lot of programming tasks.

I'm wondering, however, if we can do a bit better by strengthening the
warnings against variant syntax --- whose sole role appears to be to
confuse the user --- and provide some kind of good practice guide for
complex syntax such as functions, loops, etc.  But would anyone read it?
One of the problems with the documentation is there's too much of it,
measured by volume of text rather than by desired effect.  Sigh.

pws


      parent reply	other threads:[~2014-12-19  9:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-19  3:45 Eric Cook
2014-12-19  5:16 ` Kurtis Rader
2014-12-19  5:34 ` Bart Schaefer
2014-12-19  5:48   ` Kurtis Rader
2014-12-19  5:51     ` Kurtis Rader
2014-12-19  6:05     ` Bart Schaefer
2014-12-19 11:15   ` Eric Cook
2014-12-19  9:35 ` 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=20141219093551.5a89e4d9@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.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).