Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #432: Borg nanites have infested the server


comp / comp.lang.tcl / Re: The "leading zero means octal" thing...

SubjectAuthor
* The "leading zero means octal" thing...Kenny McCormack
+* Re: The "leading zero means octal" thing...Janis Papanagnou
|`- Re: The "leading zero means octal" thing...Kenny McCormack
+* Re: The "leading zero means octal" thing...Rich
|`- Re: The "leading zero means octal" thing...Kenny McCormack
+* Re: The "leading zero means octal" thing...Eli the Bearded
|`* Re: The "leading zero means octal" thing...Kenny McCormack
| `* Re: The "leading zero means octal" thing...Kenny McCormack
|  +- 'nf' in VIM (Was: The "leading zero means octal" thing...)Kenny McCormack
|  `- Re: The "leading zero means octal" thing...Janis Papanagnou
+- Re: The "leading zero means octal" thing...Joe Makowiec
+* Re: The "leading zero means octal" thing...Luc
|`* Re: The "leading zero means octal" thing...Rich
| `* Re: The "leading zero means octal" thing...Luc
|  +- Re: The "leading zero means octal" thing...Rich
|  `* Re: The "leading zero means octal" thing...Rich
|   `* Re: The "leading zero means octal" thing...Luc
|    `- Re: The "leading zero means octal" thing...Rich
+* Re: The "leading zero means octal" thing...saito
|`* Re: The "leading zero means octal" thing...Kenny McCormack
| `* Re: The "leading zero means octal" thing...Rich
|  `- Re: The "leading zero means octal" thing...Kenny McCormack
`- Re: The "leading zero means octal" thing...Eric Pozharski

1
Subject:
From:
Newsgroups:
Date: Sun, 19 Jan 2025 09:09 UTC
I am referring, of course, to the convention that a number with a leading
zero is interpreted as octal. I can't count the number of times I've been
bitten by this - in various languages/environments all across the Unix
ecosystem. Note the choice of newsgroups above - I have been affected by
this in each of these environments - most recently in Tcl (Expect) and in
the VIM editor.
View all headers

In fact, the really obnoxious part about it is that it means a number
string like "08" is invalid, because 8 is not a valid digit in octal. I
wish there was a global way to turn this off - some option to set that says
"Don't do that!". I realize, of course, that it has to be on by default,
but it should be possible to turn it off.

Incidentally, and this was my motivation for posting this rant, I hit this
in VIM - where if the cursor is sitting on the zero in a string like Foo07
and you hit ^A, it changes it to - are you ready? - not Foo08, but Foo010.

Totally weird and unexpected.

--
Just like Donald Trump today, Jesus Christ had a Messiah complex.

And, in fact, the similarities between the two figures are quite striking.
For example, both have a ragtag band of followers, whose faith cannot be shaken.

Subject: Re: The "leading zero means octal" thing...
From: Janis Papanagnou
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: A noiseless patient Spider
Date: Sat, 4 Jan 2025 22:54 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sat, 4 Jan 2025 23:54:15 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <vlce6p$lk3q$1@dont-email.me>
References: <vlcbrr$2ito3$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 04 Jan 2025 23:54:18 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2bdc7bee47d59c4498da5f7fc89dd24e";
logging-data="708730"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rNxgJr/pBwTqlKNM7Zz0C"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:qabUaDi9pgjA9PWZJ7rSrnghvVE=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <vlcbrr$2ito3$1@news.xmission.com>
View all headers

On 04.01.2025 23:14, Kenny McCormack wrote:
> First of all, yes, I know this is all standardized and it is based on
> legacy C conventions and it can't be changed and so on and so forth.
>
> But if not a bug, it is certainly a misfeature.
>
> I am referring, of course, to the convention that a number with a leading
> zero is interpreted as octal. I can't count the number of times I've been
> bitten by this - in various languages/environments all across the Unix
> ecosystem. Note the choice of newsgroups above - I have been affected by
> this in each of these environments - most recently in Tcl (Expect) and in
> the VIM editor.
>
> In fact, the really obnoxious part about it is that it means a number
> string like "08" is invalid, because 8 is not a valid digit in octal. I
> wish there was a global way to turn this off - some option to set that says
> "Don't do that!". I realize, of course, that it has to be on by default,
> but it should be possible to turn it off.
>
> Incidentally, and this was my motivation for posting this rant, I hit this
> in VIM - where if the cursor is sitting on the zero in a string like Foo07
> and you hit ^A, it changes it to - are you ready? - not Foo08, but Foo010.
>
> Totally weird and unexpected.

Yes.

(You can find this complaint also already mentioned on the Web
in 2012, maybe even before. I suppose it's hard to do or change
anything as default behavior now.)

As a consequence, in Kornshell, I'm using a number prefix 10# to
counter that misbehavior. (I'd suppose this works also in other
major shells like Bash.)

In Vim there's a "sensible.vim" plugin available. (But I've not
tried it.) Given the tons of options in Vim I wonder why they
haven't supported an option to fix it inherently.

Janis

Subject: Re: The "leading zero means octal" thing...
From: Rich
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: A noiseless patient Spider
Date: Sun, 5 Jan 2025 00:09 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 00:09:41 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <vlcik4$md8n$1@dont-email.me>
References: <vlcbrr$2ito3$1@news.xmission.com>
Injection-Date: Sun, 05 Jan 2025 01:10:11 +0100 (CET)
Injection-Info: dont-email.me; posting-host="8484d18e4d87a7d264be721074b3dc02";
logging-data="734487"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX198pu+buf/v1Tk5VYRLOrQ7"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:A3uN1kPIY8azRDskwLbzAsuYk7w=
View all headers

In comp.lang.tcl Kenny McCormack <gazelle@shell.xmission.com> wrote:
> I am referring, of course, to the convention that a number with a
> leading zero is interpreted as octal. ... most recently in Tcl
> (Expect) ...

For Tcl 9, leading zero decimal number strings are no longer
interpreted as octal:

https://www.tcl-lang.com/software/tcltk/9.0.html

Numbers

0NNN format is no longer octal interpretation. Use 0oNNN

Subject: Re: The "leading zero means octal" thing...
From: Eli the Bearded
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: Some absurd concept
Date: Sun, 5 Jan 2025 01:55 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 01:55:17 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2501042055@qaz.wtf>
References: <vlcbrr$2ito3$1@news.xmission.com>
Injection-Date: Sun, 5 Jan 2025 01:55:17 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="2192"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
View all headers

In comp.unix.shell, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> First of all, yes, I know this is all standardized and it is based on
> legacy C conventions and it can't be changed and so on and so forth.
>
> But if not a bug, it is certainly a misfeature.

I can see it as a legacy feature that has grown so old as to be a
misfeature. Other than bit patterns for chmod, I never see octal used
for modern stuff.

> the VIM editor.

Vim is highly configurable. See ":help nrformats" for supported formats.
Not clearly documented in the version I have, but implied, is setting
it to a blank string to only recognize ordinary decimal numbers.

:set nrformats=

If you have no vimrc, the defaults.vim shipped with the editor (vim 8)
sets that to recognize decimal, binary ("0b10101"), and hexadecimal
("0xcafe"). But the compiled in default also includes the dreaded
octal.

You might want to peruse the defaults.vim file for modern recommended
defaults. Except for scrolloff and incsearch, I don't find them that
unpleasant. I think a lot of people like incsearch, and I like scrolloff
on occaison, but not regularly.

Start vim, then ":e $VIMRUNTIME/defaults.vim" to view the defaults file.

Elijah
------
prefers vim acting mostly "compatible"

Subject: Re: The "leading zero means octal" thing...
From: Kenny McCormack
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: The official candy of the new Millennium
Date: Sun, 5 Jan 2025 05:16 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 05:16:50 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vld4k2$2jao9$1@news.xmission.com>
References: <vlcbrr$2ito3$1@news.xmission.com> <eli$2501042055@qaz.wtf>
Injection-Date: Sun, 5 Jan 2025 05:16:50 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2730761"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <eli$2501042055@qaz.wtf>,
Eli the Bearded <*@eli.users.panix.com> wrote:
....
>Vim is highly configurable. See ":help nrformats" for supported formats.
>Not clearly documented in the version I have, but implied, is setting
>it to a blank string to only recognize ordinary decimal numbers.
>
> :set nrformats=

Thanks for the tip. I'll look into that.

(And note, yes, this interchange between you & me is one of those rare
examples of Usenet working as intended. It gladdens the eye. It makes it
all worthwhile...)

--
The plural of "anecdote" is _not_ "data".

Subject: Re: The "leading zero means octal" thing...
From: Kenny McCormack
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: The official candy of the new Millennium
Date: Sun, 5 Jan 2025 05:20 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 05:20:47 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vld4rf$2jao9$2@news.xmission.com>
References: <vlcbrr$2ito3$1@news.xmission.com> <vlce6p$lk3q$1@dont-email.me>
Injection-Date: Sun, 5 Jan 2025 05:20:47 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2730761"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vlce6p$lk3q$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>As a consequence, in Kornshell, I'm using a number prefix 10# to
>counter that misbehavior. (I'd suppose this works also in other
>major shells like Bash.)

Yes, bash has that, too. But for whatever it is worth, in at least one of
my scripts, using it was inconvenient (*), so I ended up having to use "bc" to
do a calculation instead of (the more efficient/built-in) $((...)) (**).
Sort of annoying.

(*) Didn't work out, for some reason.

(**) Which had been working fine right up until it hit the dreaded "08".

--
Pensacola - the thinking man's drink.

Subject: Re: The "leading zero means octal" thing...
From: Kenny McCormack
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: The official candy of the new Millennium
Date: Sun, 5 Jan 2025 05:21 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 05:21:59 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vld4tn$2jao9$3@news.xmission.com>
References: <vlcbrr$2ito3$1@news.xmission.com> <vlcik4$md8n$1@dont-email.me>
Injection-Date: Sun, 5 Jan 2025 05:21:59 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2730761"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vlcik4$md8n$1@dont-email.me>, Rich <rich@example.invalid> wrote:
>In comp.lang.tcl Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> I am referring, of course, to the convention that a number with a
>> leading zero is interpreted as octal. ... most recently in Tcl
>> (Expect) ...
>
>For Tcl 9, leading zero decimal number strings are no longer
>interpreted as octal:
>
>https://www.tcl-lang.com/software/tcltk/9.0.html
>
> Numbers
>
> 0NNN format is no longer octal interpretation. Use 0oNNN
>

This is good news!

I guess I'm going to have to re-compile (A private version of) Tcl and
Expect (one of these days...)

--
"He is exactly as they taught in KGB school: an egoist, a liar, but talented - he
knows the mind of the wrestling-loving, under-educated, authoritarian-admiring
white male populous."
- Malcolm Nance, p59. -

Subject: Re: The "leading zero means octal" thing...
From: Kenny McCormack
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: The official candy of the new Millennium
Date: Sun, 5 Jan 2025 06:33 UTC
References: 1 2 3
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 06:33:07 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vld933$2jcih$1@news.xmission.com>
References: <vlcbrr$2ito3$1@news.xmission.com> <eli$2501042055@qaz.wtf> <vld4k2$2jao9$1@news.xmission.com>
Injection-Date: Sun, 5 Jan 2025 06:33:07 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2732625"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vld4k2$2jao9$1@news.xmission.com>,
Kenny McCormack <gazelle@shell.xmission.com> wrote:
>In article <eli$2501042055@qaz.wtf>,
>Eli the Bearded <*@eli.users.panix.com> wrote:
>...
>>Vim is highly configurable. See ":help nrformats" for supported formats.
>>Not clearly documented in the version I have, but implied, is setting
>>it to a blank string to only recognize ordinary decimal numbers.
>>
>> :set nrformats=
>
>Thanks for the tip. I'll look into that.

Yes, nf looks good. I set it to "alpha", which makes it do the right thing
with letters, while ignoring the stupid hex/octal/bin stuff.

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/Noam

Subject: 'nf' in VIM (Was: The "leading zero means octal" thing...)
From: Kenny McCormack
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: The official candy of the new Millennium
Date: Sun, 5 Jan 2025 07:05 UTC
References: 1 2 3 4
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: 'nf' in VIM (Was: The "leading zero means octal" thing...)
Date: Sun, 5 Jan 2025 07:05:29 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vldavp$2jdk0$1@news.xmission.com>
References: <vlcbrr$2ito3$1@news.xmission.com> <eli$2501042055@qaz.wtf> <vld4k2$2jao9$1@news.xmission.com> <vld933$2jcih$1@news.xmission.com>
Injection-Date: Sun, 5 Jan 2025 07:05:29 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2733696"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vld933$2jcih$1@news.xmission.com>,
Kenny McCormack <gazelle@shell.xmission.com> wrote:
>In article <vld4k2$2jao9$1@news.xmission.com>,
>Kenny McCormack <gazelle@shell.xmission.com> wrote:
>>In article <eli$2501042055@qaz.wtf>,
>>Eli the Bearded <*@eli.users.panix.com> wrote:
>>...
>>>Vim is highly configurable. See ":help nrformats" for supported formats.
>>>Not clearly documented in the version I have, but implied, is setting
>>>it to a blank string to only recognize ordinary decimal numbers.
>>>
>>> :set nrformats=
>>
>>Thanks for the tip. I'll look into that.
>
>Yes, nf looks good. I set it to "alpha", which makes it do the right thing
>with letters, while ignoring the stupid hex/octal/bin stuff.

And one more thing...

It seems nf is buffer-local, so setting it while in one buffer does not
change it globally. Setting it in .vimrc does set it globally (which makes
sense, since no other buffers exist at that point - and they all inherit
the value).

I get why this is the way it works, but am curious if there is a way to set
it globally (without exiting and re-starting VIM, of course). I have lots
of windows and buffers open and don't want to re-start.

I read "help :set" and it covers a lot, but didn't see anything
specifically on this topic.

--
I've learned that people will forget what you said, people will forget
what you did, but people will never forget how you made them feel.

- Maya Angelou -

Subject: Re: The "leading zero means octal" thing...
From: Janis Papanagnou
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Followup: comp.editors
Organization: A noiseless patient Spider
Date: Sun, 5 Jan 2025 07:39 UTC
References: 1 2 3 4
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Followup-To: comp.editors
Date: Sun, 5 Jan 2025 08:39:54 +0100
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <vldd0c$u77e$1@dont-email.me>
References: <vlcbrr$2ito3$1@news.xmission.com> <eli$2501042055@qaz.wtf>
<vld4k2$2jao9$1@news.xmission.com> <vld933$2jcih$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 05 Jan 2025 08:40:00 +0100 (CET)
Injection-Info: dont-email.me; posting-host="6ee5967cfd6763239853a04e47fb77c4";
logging-data="990446"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JtON/Y+PrEnS4U+yJxGwt"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:ml4cWOo1XkF8G1bUfUihWxJFqs4=
In-Reply-To: <vld933$2jcih$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
View all headers

[ f'up to comp.editors set ]

On 05.01.2025 07:33, Kenny McCormack wrote:
> In article <vld4k2$2jao9$1@news.xmission.com>,
> Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> In article <eli$2501042055@qaz.wtf>,
>> Eli the Bearded <*@eli.users.panix.com> wrote:
>> ...
>>> Vim is highly configurable. See ":help nrformats" for supported formats.
>>> Not clearly documented in the version I have, but implied, is setting
>>> it to a blank string to only recognize ordinary decimal numbers.
>>>
>>> :set nrformats=
>>
>> Thanks for the tip. I'll look into that.
>
> Yes, nf looks good. I set it to "alpha", which makes it do the right thing
> with letters, while ignoring the stupid hex/octal/bin stuff.

This 'alpha' is an interesting useful feature I didn't know. Thanks.
(It will go into my .vimrc file.)

Testing it I was a bit astonished, though, that (and different from
numbers) it just works on single letters without a "carry"; with the
string "say38", operating a 66^A on the number part creates "say104"
while at any character it stops increment at "z".

(I recall that I once had a requirement to enumerate some date as
aa, ab, ac, ..., az, ba, bb, ..., bz, ..., zz, and even continuing
zz with aaa, as with a numeric carry.)

Janis

Subject: Re: The "leading zero means octal" thing...
From: Joe Makowiec
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: .
Date: Sun, 5 Jan 2025 15:51 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: makowiec@invalid.invalid (Joe Makowiec)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 15:51:55 -0000 (UTC)
Organization: .
Lines: 19
Message-ID: <XnsB25E6E86F20F0makowiecatnycapdotrE@95.217.65.137>
References: <vlcbrr$2ito3$1@news.xmission.com>
Injection-Date: Sun, 05 Jan 2025 16:51:55 +0100 (CET)
Injection-Info: dont-email.me; posting-host="0c33c565964d9cf793871b6db19226ae";
logging-data="1151233"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18atTkCaduYbbdggNkbN722KtgdXP2SnGo="
User-Agent: Xnews/2009.05.01
Cancel-Lock: sha1:zFmFPNfPszwnryh1XJQ0cCTpwwU=
View all headers

On 04 Jan 2025 in comp.editors, Kenny McCormack wrote:

> I hit this in VIM - where if the cursor is sitting on the zero in a
> string like Foo07 and you hit ^A, it changes it to - are you ready?
> - not Foo08, but Foo010.

For what it's worth, I tried this in my edition of vim (v 9.1 on
Fedora 41, pretty much default). It incremented Foo07 to Foo08. I dug
into /usr/share/vim/vim91/defaults.vim and found this:

" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
" confusing.
set nrformats-=octal

--
Joe Makowiec
http://makowiec.org/
Email: http://makowiec.org/contact/?Joe
Usenet Improvement Project: http://twovoyagers.com/improve-usenet.org/

Subject: Re: The "leading zero means octal" thing...
From: Luc
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 5 Jan 2025 19:46 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 16:46:57 -0300
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <20250105164657.7eeaf441@lud1.home>
References: <vlcbrr$2ito3$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 05 Jan 2025 20:46:58 +0100 (CET)
Injection-Info: dont-email.me; posting-host="b44566700864431d72490ecc20721393";
logging-data="1242928"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dII3pwiPEJhS/+Gkh8kOMyJskUP42xd0="
Cancel-Lock: sha1:rdVleFwsGFXZso12NU716Dlni8o=
View all headers

I updated my 'seq' code because of this thread:

https://wiki.tcl-lang.org/page/seq

--
Luc
>>

Subject: Re: The "leading zero means octal" thing...
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 5 Jan 2025 21:04 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 21:04:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 70
Message-ID: <vles5e$16v92$1@dont-email.me>
References: <vlcbrr$2ito3$1@news.xmission.com> <20250105164657.7eeaf441@lud1.home>
Injection-Date: Sun, 05 Jan 2025 22:04:50 +0100 (CET)
Injection-Info: dont-email.me; posting-host="8484d18e4d87a7d264be721074b3dc02";
logging-data="1277218"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PvG0zfYc8bwietmkIZTu8"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:M4e/1vH+G5+jheqP34F0FH+4+Nk=
View all headers

Luc <luc@sep.invalid> wrote:
> I updated my 'seq' code because of this thread:
>
> https://wiki.tcl-lang.org/page/seq

And, line one of the proc contains the common Tcl bug of "applying a
string operator" to a tcl list.

Note this:

$ rlwrap tclsh
% proc p {args} { set args [string trimleft $args 0] ; return $args }
% p 08
8
% p 08 08
8 08
% p #08 08
{#08} 08
% p 08 0a "one two three"
8 0a {one two three}

The 'args' special variable to a proc is provided to the proc as a
"list".

'string trimleft' is a string operator (not a list operator). So when
'string trimleft' is applied to a list, Tcl first converts the list
into a string, the operates on the string, which will likely not
produce the expected result.

Note the second 'test' above, where 08 08 was passed to p. Because
args was converted to a string, only the initial leading zero was
removed. However it is likely that the intent was to convert 08 08
into 8 and 8. But 'string trimleft' does not work on individual list
elements, it only knows strings, and after [list 08 08] is converted to
a string, string trimleft sees "08 08" and only removes the first 0.

Next, note the third test, where #08 was passed in. It is unlikely the
intent was for #08 to become {#08} (the added {}'s are from Tcl's list
to string conversion).

Note as well the fourth test. "one two three" was changed to {one two
three}. Also not likely the intended outcome.

What this proc likely wanted was to iterate over each element in the
args list, and remove leading zeros from each element, i.e.:

proc p2 {args} { set args [lmap x $args {string trimleft $x 0}] ; return $args }

Which does the right thing for plural leading zero arguments:

% p2 08
8
% p2 08 08
8 8
% p2 08 08 08
8 8 8

Note, because the CLI does a list to string conversion when printing
the return value, we can still get 'weird characters' when showing a
demo:

% p2 #08 08 08 "this or that"
{#08} 8 8 {this or that}

But a simple tweak will show the internal contents of the list without
the extra 'stringification':

% join [p2 #08 08 08 "this or that"] |
#08|8|8|this or that

Subject: Re: The "leading zero means octal" thing...
From: saito
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: A noiseless patient Spider
Date: Sun, 5 Jan 2025 21:35 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saito)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 16:35:27 -0500
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <vletuv$17djb$1@dont-email.me>
References: <vlcbrr$2ito3$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 05 Jan 2025 22:35:28 +0100 (CET)
Injection-Info: dont-email.me; posting-host="207371964f0fc4c3cb3790018771a172";
logging-data="1291883"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QHPoSeveprNXaAbkE1cqO"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7S1BX6V8pnR5QdQc3lvt4/Hqp0o=
In-Reply-To: <vlcbrr$2ito3$1@news.xmission.com>
Content-Language: en-US
View all headers

On 1/4/2025 5:14 PM, Kenny McCormack wrote:
> First of all, yes, I know this is all standardized and it is based on
> legacy C conventions and it can't be changed and so on and so forth.
>
> But if not a bug, it is certainly a misfeature.
>
> I am referring, of course, to the convention that a number with a leading
> zero is interpreted as octal. I can't count the number of times I've been
> bitten by this - in various languages/environments all across the Unix
> ecosystem. Note the choice of newsgroups above - I have been affected by
> this in each of these environments - most recently in Tcl (Expect) and in
> the VIM editor.
>

I can't help but think that this may be related to your post regarding
time calculation. I had left this quote in my reply:

> There is an interesting "octal" problem left as an exercise 🙂

This was exactly the exercise as well. "clock format" leaves leading
zeros in the result depending on what time it was. It is missing "string
trimleft" calls which I'd discovered after some test runs before posting.

Subject: Re: The "leading zero means octal" thing...
From: Kenny McCormack
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Organization: The official candy of the new Millennium
Date: Sun, 5 Jan 2025 21:55 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 21:55:10 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vlev3u$2k7dc$1@news.xmission.com>
References: <vlcbrr$2ito3$1@news.xmission.com> <vletuv$17djb$1@dont-email.me>
Injection-Date: Sun, 5 Jan 2025 21:55:10 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2760108"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vletuv$17djb$1@dont-email.me>, saito <saitology9@gmail.com> wrote:
....
>I can't help but think that this may be related to your post regarding
>time calculation. I had left this quote in my reply:
>
>> There is an interesting "octal" problem left as an exercise
>
>This was exactly the exercise as well. "clock format" leaves leading
>zeros in the result depending on what time it was. It is missing "string
>trimleft" calls which I'd discovered after some test runs before posting.

It is, in fact, related to that other thread. In fact, I had developed an
entirely different solution to that problem (very short, in fact) which had
been running fine for a few weeks until it happened to hit the dreaded "08"
and crashed. I fixed that basically by adding code using "regsub" to
remove any leading zero before doing the calculations.

I'll have to take a look at "string trimleft".

--
Which of these is the crazier bit of right wing lunacy?
1) We've just had another mass shooting; now is not the time to be talking about gun control.

2) We've just had a massive hurricane; now is not the time to be talking about climate change.

Subject: Re: The "leading zero means octal" thing...
From: Luc
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 5 Jan 2025 23:13 UTC
References: 1 2 3
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: The "leading zero means octal" thing...
Date: Sun, 5 Jan 2025 20:13:01 -0300
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <20250105201301.1fe87ba4@lud1.home>
References: <vlcbrr$2ito3$1@news.xmission.com>
<20250105164657.7eeaf441@lud1.home>
<vles5e$16v92$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 06 Jan 2025 00:13:02 +0100 (CET)
Injection-Info: dont-email.me; posting-host="26e21046964ae59aa6f9b4ae9aa6300b";
logging-data="1315428"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NbV2Ap94Zas+BMNnPO4MaEkqpisB+qkA="
Cancel-Lock: sha1:sTtOyQ1nmiapmBCHV6D43NsWLwU=
View all headers

On Sun, 5 Jan 2025 21:04:46 -0000 (UTC), Rich wrote:

>Luc <luc@sep.invalid> wrote:
>> I updated my 'seq' code because of this thread:
>>
>> https://wiki.tcl-lang.org/page/seq
>
>And, line one of the proc contains the common Tcl bug of "applying a
>string operator" to a tcl list.

**************************

While I admit that I never took the list to string conversion into
consideration (I am repeat offender at that), you explore certain
possibilities in your exposition that I did take into consideration,
and I decided that those don't matter.

Anyone who has ever used seq (or just merely understands it in spite
of never having used it) knows what the input is supposed to be: two
or three integers.

I improved on it by adding the ability to produce alphabetic sequences.

About your examples, being atypically blunt, no programmer is stupid
enough to input 08 and 08. Even I wouldn't that. Likewise, no programmer
will be stupid enough to input #08. And if anyone actually does that,
they will get the empty string. The code intentionally refuses to
produce output when the input is incorrect.

Of course, we have to consider the possibility of input being generated
by some other code, which makes it more unpredictable. But then the
blame will fall upon the code that produces incorrect input, and
whoever writes (and hopefully tests) such code will have to make sure
that the input is always correct. I can't blame the authors of the
list and string commands to be responsible for my repeated incorrect
use of lists and strings.

But of course I am glad you chimed in once again because I was getting
wrong outputs for '08 08' and '08 09'. I also noted another bug that
you didn't point out: 'p.seq 0 5' was outputting '1 2 3 4 5' without
the zero, which was also incorrect.

So thanks to you, I have updated the code once again.

Thank you.

--
Luc
>>

Subject: Re: The "leading zero means octal" thing...
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 6 Jan 2025 03:03 UTC
References: 1 2 3 4
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: The "leading zero means octal" thing...
Date: Mon, 6 Jan 2025 03:03:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <vlfh5a$1ande$1@dont-email.me>
References: <vlcbrr$2ito3$1@news.xmission.com> <20250105164657.7eeaf441@lud1.home> <vles5e$16v92$1@dont-email.me> <20250105201301.1fe87ba4@lud1.home>
Injection-Date: Mon, 06 Jan 2025 04:03:17 +0100 (CET)
Injection-Info: dont-email.me; posting-host="aacc148df4532970fbc7162b818dee32";
logging-data="1400238"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZP26Sc5a48ktc2y6bSVIN"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:n5Kpnbo5ts1g2spgFDiYYotxU8I=
View all headers

Luc <luc@sep.invalid> wrote:
> On Sun, 5 Jan 2025 21:04:46 -0000 (UTC), Rich wrote:
>
>>Luc <luc@sep.invalid> wrote:
>>> I updated my 'seq' code because of this thread:
>>>
>>> https://wiki.tcl-lang.org/page/seq
>>
>>And, line one of the proc contains the common Tcl bug of "applying a
>>string operator" to a tcl list.
>
> **************************
>
> While I admit that I never took the list to string conversion into
> consideration (I am repeat offender at that), you explore certain
> possibilities in your exposition that I did take into consideration,
> and I decided that those don't matter.
>
> Anyone who has ever used seq (or just merely understands it in spite
> of never having used it) knows what the input is supposed to be: two
> or three integers.
>
> I improved on it by adding the ability to produce alphabetic sequences.
>
> About your examples, being atypically blunt, no programmer is stupid
> enough to input 08 and 08. Even I wouldn't that. Likewise, no programmer
> will be stupid enough to input #08. And if anyone actually does that,
> they will get the empty string. The code intentionally refuses to
> produce output when the input is incorrect.

And, of course, you miss the forest due to focusing on the trees.

For this trivial example, the list to string conversion is not a "big
deal". The greater point, and the one you should have taken from this,
is that applying string operators willy-nilly to things that are
documented as lists (or that contain lists) creates subtle, data
dependent, bugs that can lie in wait for a very long time before "just
the right data pattern" arrives that triggers the bug. This often
occurs weeks or months (or longer) after one initially wrote the code,
and it has been working perfectly since then, and then mysteriously, it
fails. Those bugs can be very troublesome to track down.

By being careful up front with "string operators" for "strings" and
"list operators" for "lists" you can avoid an entire class of subtle,
surprise, bugs that are hard to track down (even more so after you've
long forgotten why you wrote what you wrote).

Subject: Re: The "leading zero means octal" thing...
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 6 Jan 2025 03:12 UTC
References: 1 2 3 4
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: The "leading zero means octal" thing...
Date: Mon, 6 Jan 2025 03:12:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <vlfhng$1ande$2@dont-email.me>
References: <vlcbrr$2ito3$1@news.xmission.com> <20250105164657.7eeaf441@lud1.home> <vles5e$16v92$1@dont-email.me> <20250105201301.1fe87ba4@lud1.home>
Injection-Date: Mon, 06 Jan 2025 04:12:49 +0100 (CET)
Injection-Info: dont-email.me; posting-host="aacc148df4532970fbc7162b818dee32";
logging-data="1400238"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sMLy1/BaTbNvW9NeZICRO"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:r4USznsKp7x8f8W7iWGxSNYtlBM=
View all headers

Luc <luc@sep.invalid> wrote:
> So thanks to you, I have updated the code once again.

You do know about the "foreach" loop, that specifically iterates across
each element of a list, right?

Even if you don't want to use lmap (which does require 8.6 IIRC) you
don't need a C style "for" loop to iterate a list. Your "for {set x 0}
loop could be something like:

set cleanargs {}
foreach arg $args {
if {[string length $arg] > 1} {
lappend cleanargs [string trimleft $arg 0]
} else {
lappend cleanargs $arg
}
}

Alternately, since you are recreating seq, which only expects numbers
as args, you could do:

set cleanargs {}
foreach arg $args {
lappend cleanargs [scan $arg %d]
}

Which will handle any number of leading zeros (while producing decimal
output) and will error out on non-numeric inputs.

And, if you are willing to use lmap, the above four lines can become
this single line:

set args [lmap arg $args {scan $arg %d}]

Subject: Re: The "leading zero means octal" thing...
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 6 Jan 2025 03:15 UTC
References: 1 2 3
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: The "leading zero means octal" thing...
Date: Mon, 6 Jan 2025 03:15:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <vlfhs3$1ande$3@dont-email.me>
References: <vlcbrr$2ito3$1@news.xmission.com> <vletuv$17djb$1@dont-email.me> <vlev3u$2k7dc$1@news.xmission.com>
Injection-Date: Mon, 06 Jan 2025 04:15:15 +0100 (CET)
Injection-Info: dont-email.me; posting-host="aacc148df4532970fbc7162b818dee32";
logging-data="1400238"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nFQTMmdZt/fIZcna0XhOB"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:GeDKgeaoxGPhQjMiDkXlFMNWacQ=
View all headers

Posting groups and followup trimmed as this is Tcl specific:

In comp.lang.tcl Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <vletuv$17djb$1@dont-email.me>, saito <saitology9@gmail.com> wrote:
> ...
>>I can't help but think that this may be related to your post regarding
>>time calculation. I had left this quote in my reply:
>>
>>> There is an interesting "octal" problem left as an exercise
>>
>>This was exactly the exercise as well. "clock format" leaves leading
>>zeros in the result depending on what time it was. It is missing "string
>>trimleft" calls which I'd discovered after some test runs before posting.
>
> It is, in fact, related to that other thread. In fact, I had developed an
> entirely different solution to that problem (very short, in fact) which had
> been running fine for a few weeks until it happened to hit the dreaded "08"
> and crashed. I fixed that basically by adding code using "regsub" to
> remove any leading zero before doing the calculations.
>
> I'll have to take a look at "string trimleft".

The canonical Tcl way to handle decimal number strings with leading
zeros is to filter them through [scan] using the %d scan pattern.

$ rlwrap tclsh
% scan 08 %d
8
% scan 00000000000000000000008 %d
8
%

Subject: Re: The "leading zero means octal" thing...
From: Luc
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 6 Jan 2025 04:42 UTC
References: 1 2 3 4 5
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: The "leading zero means octal" thing...
Date: Mon, 6 Jan 2025 01:42:33 -0300
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <20250106014233.3f355b48@lud1.home>
References: <vlcbrr$2ito3$1@news.xmission.com>
<20250105164657.7eeaf441@lud1.home>
<vles5e$16v92$1@dont-email.me>
<20250105201301.1fe87ba4@lud1.home>
<vlfhng$1ande$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 06 Jan 2025 05:42:34 +0100 (CET)
Injection-Info: dont-email.me; posting-host="26e21046964ae59aa6f9b4ae9aa6300b";
logging-data="1553717"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18c7UL0bvE+M/NuPJ1JGOJ3cgrdTn7Pvxg="
Cancel-Lock: sha1:dYRA7qKnzCX+gqGjCEeEvNVM0b0=
View all headers

On Mon, 6 Jan 2025 03:12:48 -0000 (UTC), Rich wrote:

>And, if you are willing to use lmap, the above four lines can become
>this single line:
>
> set args [lmap arg $args {scan $arg %d}]
>
**************************

You are not going to believe this:

I never knew that lmap existed.

I've known lassign for a very long time.
Never knew about lmap until today.

--
Luc
>>

Subject: Re: The "leading zero means octal" thing...
From: Eric Pozharski
Newsgroups: comp.lang.tcl, comp.unix.shell, comp.editors
Followup: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 6 Jan 2025 08:24 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: apple.universe@posteo.net (Eric Pozharski)
Newsgroups: comp.lang.tcl,comp.unix.shell,comp.editors
Subject: Re: The "leading zero means octal" thing...
Followup-To: comp.unix.shell
Date: Mon, 06 Jan 2025 08:24:54 +0000
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <slrnvnn4qm.ro4.apple.universe@freight.zombinet>
References: <vlcbrr$2ito3$1@news.xmission.com>
Injection-Date: Mon, 06 Jan 2025 11:33:15 +0100 (CET)
Injection-Info: dont-email.me; posting-host="5503e537a34553856204283a68ec2277";
logging-data="1664938"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19oA8IuO+vKFmZtwZAVCJvz"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:oMExDb0ya1y+C2FWO9TqUDRG4xY=
View all headers

["Followup-To:" header set to comp.unix.shell.] # because tcl and vim are covered.

with <vlcbrr$2ito3$1@news.xmission.com> Kenny McCormack wrote:
> First of all, yes, I know this is all standardized and it is based on
> legacy C conventions and it can't be changed and so on and so forth.
*CUT* [ 16 lines 1 level deep]
> Totally weird and unexpected.

Quick grep through bash.info yelded nothing. But there is hope -- come
to the dark side, zsh has cookies:

% echo $(( 010 - 1 ))
9

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom

Subject: Re: The "leading zero means octal" thing...
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 6 Jan 2025 12:54 UTC
References: 1 2 3 4 5 6
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: The "leading zero means octal" thing...
Date: Mon, 6 Jan 2025 12:54:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <vlgjpp$1kd1t$1@dont-email.me>
References: <vlcbrr$2ito3$1@news.xmission.com> <20250105164657.7eeaf441@lud1.home> <vles5e$16v92$1@dont-email.me> <20250105201301.1fe87ba4@lud1.home> <vlfhng$1ande$2@dont-email.me> <20250106014233.3f355b48@lud1.home>
Injection-Date: Mon, 06 Jan 2025 13:54:19 +0100 (CET)
Injection-Info: dont-email.me; posting-host="aacc148df4532970fbc7162b818dee32";
logging-data="1717309"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jZwWFgP91ADLzKhalgqit"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:Q6KV2m4Zb7KjYvp0XDkwnK8+lno=
View all headers

Luc <luc@sep.invalid> wrote:
> On Mon, 6 Jan 2025 03:12:48 -0000 (UTC), Rich wrote:
>
>>And, if you are willing to use lmap, the above four lines can become
>>this single line:
>>
>> set args [lmap arg $args {scan $arg %d}]
>>
> **************************
>
> You are not going to believe this:
>
> I never knew that lmap existed.
>
> I've known lassign for a very long time.
> Never knew about lmap until today.

In your defense, it was only introduced with Tcl 8.6, so it is one of
the newer additions.

Subject: Re: The "leading zero means octal" thing...
From: Kenny McCormack
Newsgroups: comp.lang.tcl
Organization: The official candy of the new Millennium
Date: Mon, 6 Jan 2025 16:08 UTC
References: 1 2 3 4
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.tcl
Subject: Re: The "leading zero means octal" thing...
Date: Mon, 6 Jan 2025 16:08:38 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vlgv66$2l6tg$1@news.xmission.com>
References: <vlcbrr$2ito3$1@news.xmission.com> <vletuv$17djb$1@dont-email.me> <vlev3u$2k7dc$1@news.xmission.com> <vlfhs3$1ande$3@dont-email.me>
Injection-Date: Mon, 6 Jan 2025 16:08:38 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2792368"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vlfhs3$1ande$3@dont-email.me>, Rich <rich@example.invalid> wrote:
....
>The canonical Tcl way to handle decimal number strings with leading
>zeros is to filter them through [scan] using the %d scan pattern.
>
> $ rlwrap tclsh
> % scan 08 %d
> 8
> % scan 00000000000000000000008 %d
> 8
> %
>

That's good to know.

--
(Cruz certainly has an odd face) ... it looks like someone sewed pieces of a
waterlogged Reagan mask together at gunpoint ...

http://www.rollingstone.com/politics/news/how-america-made-donald-trump-unstoppable-20160224

1

rocksolid light 0.9.8
clearnet tor