-
Notifications
You must be signed in to change notification settings - Fork 66
RFC: Octal integer literals #133
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
base: master
Are you sure you want to change the base?
Conversation
|
The main motivation for octals, imo, is when doing any interaction with a Linux filesystem, as they use octals for file permissions. Could be worth mentioning in the RFC? (As a sidenote, you might want to remove Python from the title, both because the word "Python" may turn some people away, and because they're prevalent in plenty of other languages. JS, Ruby and Rust to name a few) |
|
Python 3 was the first language to introduce the wrt. Unix file permissions I don't think there's much convincing anyone that this isn't a very niche feature. I was considering just opening a PR to the Luau repo since the actual change is just 3 lines (everything else is added warnings/tests) but since it says to open an RFC for feature additions I thought I should listen. Maybe I'll just make it anyway and see |
|
I dunno about turning people away, but I do not think the title of an RFC should ever say "PopularLanguage-style." It feels weird. You're proposing the feature for Luau, it has nothing to do with Python in any way beyond maybe you having been inspired by it in Python. We're not going to accept e.g. the idea that whatever Python changes with this feature in the future, we'll also change in precisely the same way. This is indeed a language feature addition though, and it does indeed require an RFC. I would just frame it, especially in title, as just the feature you're proposing (Octal integer literals), and discuss any inspiration for the design today in the body of the RFC. |
|
Thanks, you raise some good points. I agree, this doesn't really have much connection to Python other than the notation originally coming from it. (also it makes it look as if the reason for the RFC is to just add it because Python has it) Will revise the document, kinda forgot they stay in the repo forever (i think), I wrote it in like 10 minutes it's not organized very well either |
|
Yeah, no worries, the actual feature is fine afaik, just need the doc describing it to be more polished since it exists in perpetuity. |
| ## Motivation | ||
|
|
||
| Some legacy systems use octal extensively, and converting from octal to other bases to interface with them can be a chore. For example, the PDP-11 uses octal extensively - its instruction encodings are a natural fit for octal as they are arranged in groups of 3 bits, and octal is used to represent addresses & words in nearly all materials. | ||
|
|
||
| Unix also uses octal to represent file permissions (e.g. in commands like `chmod 755`), and this is perhaps the most recognisable use of it today. | ||
|
|
||
| Many other languages (Python, JavaScript, Rust...) also support octal literals in this style, so it allows for more straightforward porting of code. | ||
|
|
||
| The audience for this feature is admittedly small, but the parser provisions for supporting hexadecimal and binary literals extend easily onto adding octal literals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is actually a motivation, it's just a description of why you'd want to use octals in general. It doesn't answer why Luau should have them beyond "it makes porting code easier".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you're right, it is pretty much just a list of octal facts.. I'm not sure what would be better to put there, though. The real story is just I was writing a PDP-11 emulator and got annoyed at having to constantly have an octal converter open lol. Went to see how easy it would be to implement (it's basically 3 lines) but wasn't really ready for all the red tape
Rendered
Implementation PR