zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: two mysteries
Date: Sat, 07 Nov 2015 07:19:29 -0800	[thread overview]
Message-ID: <563E1681.4000306@eastlink.ca> (raw)
In-Reply-To: <151107015534.ZM23371@torch.brasslantern.com>

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.



  reply	other threads:[~2015-11-07 15:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 18:12 Ray Andrews
2015-11-04 20:35 ` Bart Schaefer
2015-11-05  0:38   ` Ray Andrews
2015-11-06 18:44     ` Bart Schaefer
2015-11-06 22:22       ` Ray Andrews
2015-11-07  9:55         ` Bart Schaefer
2015-11-07 15:19           ` Ray Andrews [this message]
2015-11-07 17:19             ` Bart Schaefer
2015-11-07 18:37               ` Ray Andrews

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=563E1681.4000306@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --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).