zsh-users
 help / color / mirror / code / Atom feed
From: Meino Christian Cramer <Meino.Cramer@gmx.de>
To: schaefer@brasslantern.com
Cc: zsh-users@sunsite.dk
Subject: Re: Airthmetic confusion...
Date: Tue, 17 May 2005 16:57:49 +0200 (CEST)	[thread overview]
Message-ID: <20050517.165749.74751175.Meino.Cramer@gmx.de> (raw)
In-Reply-To: <1050517034852.ZM26898@candle.brasslantern.com>

From: Bart Schaefer <schaefer@brasslantern.com>
Subject: Re: Airthmetic confusion...
Date: Tue, 17 May 2005 03:48:52 +0000

Thanks a lot for your explicit explanations.

Meino


> On May 17,  5:13am, Meino Christian Cramer wrote:
> }
> }  I see that "0" is false and !0 is true...but...we
> }  are doing arithmetic and not logical evaluation.
> 
> No, that's not true.
> 
> First of all, the closest thing to "logical" evaluation that the
> shell does is the &&, ||, etc., subexpressions WITHIN arithmetic
> expressions.  The && and || constructs that test process success
> or failure are NOT "logical" operators -- for one thing, they do
> not obey the usual Boolean precedence rules.  "set -e" is not a
> "logical" comparison by any stretch.
> 
> Second, when you write (( expression )) then you are explicitly
> instructing the shell to do BOTH arithmetic evaluation AND shell
> expression success/failure.  That's what the double parens MEAN,
> when not preceded by a dollar sign.
> 
> If you want ONLY arithmetic evaluation, use $(( expression )),
> and apply the colon command if necessary, e.g.
> 
>     : $(( x = a - b ))
> 
> or
> 
>     x=$(( a - b ))
> 
> Those are both successful shell expressions that result in zero-
> value assignments to x.
> 
> As with any other programming language, you have to write exactly
> what you mean, and you have to follow the language's semantic rules,
> not the rules as you think they should be.
> 
> }  As a sideffect a previously existant variable become inexistant by
> }  assigning a "0"?
> 
> What makes you believe that's happening?  Assignments can only create
> variables, they can't unset them.
> 


  parent reply	other threads:[~2005-05-17 14:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-16 17:55 Meino Christian Cramer
2005-05-16 20:43 ` Matthias Berndt
2005-05-16 20:59   ` Mike Hernandez
2005-05-16 21:46     ` Dan Nelson
2005-05-17  1:19       ` Mike Hernandez
2005-05-16 23:39     ` Matthias Berndt
2005-05-17  3:13     ` Meino Christian Cramer
2005-05-17  3:48       ` Bart Schaefer
2005-05-17 11:26         ` Mike Hernandez
2005-05-17 14:57         ` Meino Christian Cramer [this message]
2005-05-17  3:14   ` Meino Christian Cramer

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=20050517.165749.74751175.Meino.Cramer@gmx.de \
    --to=meino.cramer@gmx.de \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.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).