From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7266 invoked by alias); 7 Nov 2015 15:19:33 -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: 20915 Received: (qmail 14084 invoked from network); 7 Nov 2015 15:19:32 -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-Authority-Analysis: v=2.1 cv=T/C1EZ6Q c=1 sm=1 tr=0 a=NKvc7L9z7/b0bXwZ1ZmuGA==:117 a=NKvc7L9z7/b0bXwZ1ZmuGA==:17 a=N659UExz7-8A:10 a=7VwfYyw5FDAtBaa2muUA:9 a=pILNOxqGKmIA:10 Message-id: <563E1681.4000306@eastlink.ca> Date: Sat, 07 Nov 2015 07:19:29 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: two mysteries References: <563A4A75.1020009@eastlink.ca> <151104123546.ZM20556@torch.brasslantern.com> <563AA51B.3040101@eastlink.ca> <151106104455.ZM22748@torch.brasslantern.com> <563D281F.1000304@eastlink.ca> <151107015534.ZM23371@torch.brasslantern.com> In-reply-to: <151107015534.ZM23371@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit On 11/07/2015 01:55 AM, Bart Schaefer wrote: > My only guess is that in some cases the assignment occurs before the > declaration: > > torch% START_IDX=1+((idx-1)/page_hight)*page_hight > torch% print ${(t)START_IDX} > scalar > torch% integer START_IDX > zsh: division by zero > torch% print ${(t)START_IDX} > integer > torch% > > The value currently in the scalar $START_IDX is evaluated when the type > changes to integer, which causes the division by zero. > I think you bagged it. The type is changed *even* when the assignment fails, that didn't even occur to me. And yes, the logic is sound--it *has* to be an integer for 'division by zero' to be a relevant message. I think where I went off the rails is that this was part of my trying to pass arrays (as we discussed) rather than flocks of independent values, and whereas I had at one time: integer page_hight this became: files[page_hight] ... and (so far) I don't know how to typeset an element of an array so it was a bloody scalar and became an integer even when it failed to be assigned--so tweedle-dum was in fact tweedle-dee and I had the right issue but the bassackwards interpretation. And, as the clouds part, I now think I know how I fixed it: files[page_hight]=$files_frame[page_hight] files[page_hight]=$(( files_frame[page_hight] )) ... because when I forced it to be integer all the arithmetic ducks lined up ... or something very much like that. It's actually a long chain of arithmetics, but I'll be primed for this next time something like that happens. I'm hunting ducks holding my shotgun backwards. Geez, I wish we had in inviolable integer. } Didn't I read that } there's a difference between 'typeset -i' and 'integer'? Read where ...? Doc: I dunno, I just vaguely recall something, thought I'd ask. Something in 1st Peter, I think--some subtlety ... nevermind. Masterful, Sensei.