-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove octal literals misfeature #417
Conversation
Woah. I was not aware of that. @JeffBezanson, were you? |
Remove octal literals misfeature
Btw, while we're on the subject, how do you feel about hex literals for unsigned ints? Feature or misfeature? |
Do we genuinely not want octal literals? Is there something bad about them? Doesn't matter to me much either way, just curious if this is a real problem somehow. |
They're probably not a real problem. Re: hex |
Ok, I agree with that. Better to err on the side of fewer features. And if you really want octal |
You might try a more explicit prefix for octal such as |
Re: hex, having hexadecimal floating-point syntax would be nice too. Hex floats are useful for precisely reading and writing float values as text. |
Octal literals might be useful for functions which set filesystem permissions, e.g., |
I agree that having octal literals could be useful if we were using a better prefix like |
|
python3 decided to use I think i'll go ahead and add |
|
We could also just interpret the decimal value 755 as though it were octal when passing integers as permission masks. |
I like this, but I feel it also breaks away from most other programming language implementations. I know Python and C are both octal-based, are there any examples of programming languages that use decimal permissions? (If only there were a way to auto-detect and give the best of both worlds. :P ) |
Interpreting decimal values as though they were octal also has the issue that bitwise operations don't work right: julia> 755 & 666
658
julia> oct(0o755 & 0o666)
"644" |
Oof, yeah, that's a killer. I, personally, would expect bitwise operations to work when it comes to file permissions. Perhaps we should just let this one be, and make notes in the documentation that permissions should be passed as |
This is still a problem with BigInt, when it's given a string argument: julia> BigInt(033)
33 # works as expected
julia> BigInt("033")
27 # doesn't; it was interpreted as octal. |
Oh, that's not good at all. Thanks for point it out. |
Currently Julia has octal integer literals, like this:
julia> 010 8
Since they are not mentioned in the manual (as opposed to hex literals) I assume they are an accident, inherited from femtolisp's one-argument
string->number
implementation.So here's my try at fixing this.