zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Ray Andrews <rayandrews@eastlink.ca>, zsh-users@zsh.org
Subject: Re: suprise with -=
Date: Tue, 20 Oct 2015 20:52:54 -0700	[thread overview]
Message-ID: <151020205254.ZM1906@torch.brasslantern.com> (raw)
In-Reply-To: <5626FE9D.9020003@eastlink.ca>

On Oct 20,  7:55pm, Ray Andrews wrote:
} Subject: Re: suprise with -=
}
} On 10/19/2015 05:27 PM, Bart Schaefer wrote:
} > 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
} 
} Then what does 'integer' or 'typset -i' do?

They declare that the internal representation of the variable should be
an integer, so that integer formatting may be applied when the variable
is converted back to a value with $first.

} I can't help but wonder what was going on in the minds of the guys who
} coded the first shells

The first shells didn't have integers or arrays at all.  They had only
strings, and a few (external) programs like "expr" that could interpret
strings of digits as numbers.

Arrays came next and numbers/math last of all, so numbers must conform
to the rules established when the shell was strings-only.  Shells were
never intended to look or behave anything like C (well, except for csh,
but it was only supposed to look like C, not act like it, and it got a
lot of other things wrong).


  reply	other threads:[~2015-10-21  3:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-19  5:46 Ray Andrews
2015-10-19 18:35 ` Bart Schaefer
2015-10-19 19:34   ` Ray Andrews
2015-10-20  0:27     ` Bart Schaefer
2015-10-21  2:55       ` Ray Andrews
2015-10-21  3:52         ` Bart Schaefer [this message]
2015-10-21 18:01       ` Ray Andrews
2015-10-21 18:43         ` ZyX
2015-10-22 15:29           ` Ray Andrews
2015-10-22 15:43             ` ZyX
2015-10-22 16:02               ` Ray Andrews
2015-10-22 23:56               ` Bart Schaefer
2015-10-23  7:34                 ` Daniel Shahaf
2015-10-21 18:46         ` Bart Schaefer

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=151020205254.ZM1906@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=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).