From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28442 invoked by alias); 20 Oct 2015 00:27:54 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20796 Received: (qmail 28782 invoked from network); 20 Oct 2015 00:27:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) 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.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=2XTMwXh6v/vsSuLGGP/xHbi+AU//TCaQvJ4abGQeZmI=; b=lbTHt/l6OKv2xyyKnf+Cv2F0MY4ippW5K1NBtQxfJAkmqDrwN1Bm6F2eF28pFF6lhw QSUWWj2NnlMpZZc2Iux2C1gi0vF7MRSmwyD8jcjicuDZGLcQOYRv0QIiY50shnx3BhwN 5prqBfnOThaAIHBeZH+myRrdSRBiQaA+8Jgf4WQ41ul7EHo0unf+xoB90UXMZhnW6zeW hzsg7tCsEwamWrGmYQaRDBWNJmuo3hWs3Vv8DDwOwN4h9QALV1pPoXFXLfwqWfyeYHeD nuXBeBJbrfup9BYRKVKw2ZY2ErlGbrTUhkZkTvHfHyu9yPS7SK4EtvLHbFEs8Qxx216m kj9g== X-Gm-Message-State: ALoCoQmYkrjVQ4lwmp16+qI9aj44Jnw1o6d3QvHNYnDEhfhbQDWAqPsU42/TymYzY4NS7s3juf4B X-Received: by 10.182.40.166 with SMTP id y6mr161801obk.42.1445300867495; Mon, 19 Oct 2015 17:27:47 -0700 (PDT) From: Bart Schaefer Message-Id: <151019172744.ZM558@torch.brasslantern.com> Date: Mon, 19 Oct 2015 17:27:44 -0700 In-Reply-To: <562545DD.5020008@eastlink.ca> Comments: In reply to Ray Andrews "Re: suprise with -=" (Oct 19, 12:34pm) References: <562483C9.1060602@eastlink.ca> <151019113517.ZM32739@torch.brasslantern.com> <562545DD.5020008@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: suprise with -= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 19, 12:34pm, Ray Andrews wrote: } } [...] declare variable types, which is what I'm trying to do with } 'integer' and after that I'd expect both increment and decrement to } behave the same way. The parser doesn't know that "first" is an integer, or even that it's a variable that was previously declared. This is perfectly legal: if (( RANDOM % 7 )) then integer first else declare first fi first+=second (Which is why I'm inclined to say it ought to always be string context when not explicitly math context, but it's probably way to late for that.) } I'd consider it very rude for any forcible conversions to occur. } Better an error, tho again once one has declared an integer one might } expect one's operators to behave consistently. Note: torch% integer first=1 second=2 torch% first+=(second) torch% echo $first 1 second This has silently forced $first to change into an array because of explicit array context; it did not interpret "(second)" as arithmetic parens. Also just to mess things up a bit more: torch% integer first=1 second=2 torch% third=first+second torch% print $third first+second torch% integer third torch% print $third 3 If something has a string value and you re-declare it integer, it does math on its string value. Doesn't happen for array to integer.