Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 43 |
Nodes: | 6 (0 / 6) |
Uptime: | 102:31:51 |
Calls: | 290 |
Files: | 905 |
Messages: | 76,557 |
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.
I am referring, of course, to the convention that a number with a
leading zero is interpreted as octal. ... most recently in Tcl
(Expect) ...
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.
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=
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.)
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
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.
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.
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.
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.
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.
First of all, yes, I know this is all standardized and it is based on*CUT* [ 16 lines 1 level deep]
legacy C conventions and it can't be changed and so on and so forth.
Totally weird and unexpected.