On Fri, Mar 13, 2009 at 2:14 PM, Luke VanderHart
<[email protected]> wrote:
>
> Well! You learn something new every day.
>
> Ironically, I knew about octal, but back in the day when I was
> learning Java, the book I was reading didn't have a typeface that
> distinguished O and 0 very well, and since I never had to use them I
> never was corrected. Interesting.
This is pretty standard behaviour. Here's Python:
>>> 07
7
>>> 08
File "<stdin>", line 1
08
^
SyntaxError: invalid token
>>> 010
8
>>>
And perl:
$ perl -e 'print 07, "\n";'
7
$ perl -e 'print 08, "\n";'
Illegal octal digit '8' at -e line 1, at end of line
Execution of -e aborted due to compilation errors.
Although perl gives you a better error message.
And the Unix "printf" command line tool:
$ printf "%d\n" 07
7
$ printf "%d\n" 08
-bash: printf: 08: invalid number
0
And C:
$ gcc -c /tmp/octal.c
/tmp/octal.c:7:20: error: invalid digit "8" in octal constant
/tmp/octal.c: In function 'main':
/tmp/octal.c:9: error: expected ';' before '}' token
I don't know Ruby, but it appears to do the same:
$ ruby
print 07, "\n"
print 08, "\n"
-:2: Illegal octal digit
print 08, "\n"
^
On the other hand, it's not universal.
sbcl:
* 07
7
* 08
8
--
Michael Wood <[email protected]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---