zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: Numbers with leading _
Date: Mon, 21 Nov 2022 17:22:17 +0100	[thread overview]
Message-ID: <CAHYJk3Q4f+dpwv6GDP=ZXTcjwnBc7GS+vS_G6M4Fso55zv4J6w@mail.gmail.com> (raw)

I was playing with extending hasbraces+xpandbraces to allow _ in
numbers via zstrtoul_underscore, and noticed that in normal math
context, this happens:
% echo $(( _1000 ))
0
% a=(1 2 3); echo $a[_1]

% a=(1 2 3); echo $a[1_]
1

but my modifications worked fine:
% echo {_999_.._1_0_0_1_}
999 1000 1001

Obviously there's no real reason why anyone should want to specify a
number with a leading underscore but is there a reason to reject it in
the normal math context, and should we print some kind of error when
we do it rather than silently parse it as a 0?

I didn't yet try to track down where this rejection happens, but it's
at least not in zstrtoul_underscore.

-- 
Mikael Magnusson


             reply	other threads:[~2022-11-21 16:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 16:22 Mikael Magnusson [this message]
2022-11-21 16:27 ` Peter Stephenson
2022-11-22  5:07   ` Mikael Magnusson

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='CAHYJk3Q4f+dpwv6GDP=ZXTcjwnBc7GS+vS_G6M4Fso55zv4J6w@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@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).