-
Notifications
You must be signed in to change notification settings - Fork 391
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
RFC: Floor division operator #832
Conversation
I'm sorry, I couldn't find a way to add the "rfc" label to this PR before or after creating it :/ |
Thanks Alexander! |
New revision: minor styling tweaks, added //= |
Anecdotal stats based on Roblox internal codebase (~1-2 MLOC, ~10-20M bytecode instructions):
Obviously our codebase is a bit biased in that it doesn't do a whole lot of integer math directly. There could also be some divisions that assume divisibility and forget/omit rounding; the code base has a grand total of 4567 division operators, so some percentage of these might be bugs, or the value might be implicitly rounded later (eg when passed to a C API). |
Something else that might be worth mentioning is precedents around this in other languages (except for Lua 5.3 which obviously supports this as proposed).
|
Thanks, that's a nice list! I also did some research on other languages (not as extensive as yours), but decided not to have it in the RFC because "it's supported by language X" is sometimes not a good selling point :) But you're right that someone coming from those languages would be more at home if Luau also had this operator. Should I add these to the RFC? |
I don't think we need this exhaustive list, but maybe just mention that the feature has precedents in other languages (listed). One other thing I was thinking of in regards to this proposal is that it can help us clean up the relationship between primitive operators for |
@zeux Good points, thanks! Agreed about it clarifying the semantics. I've tweaked the RFC and added Python, R and Lua as examples of other languages having floor division operator. |
We created a project internally to get this RFC scheduled and implemented. |
Great news, thanks! |
Just letting you know that this RFC is being implemented and feature might be available next week. |
- Updated Roblox copyright to 2023 - Floor division operator `//` (implements #832) - Autocomplete now shows `end` within `do` blocks - Restore BraceType when using `Lexer::lookahead` (fixes #1019) # New typechecker - Subtyping tests between metatables and tables - Subtyping tests between string singletons and tables - Subtyping tests for class types # Native codegen - Fixed macOS test failure (wrong spill restore offset) - Fixed clobbering of non-volatile xmm registers on Windows - Fixed wrong storage location of SSA reg spills - Implemented A64 support for add/sub extended - Eliminated zextReg from A64 lowering - Remove identical table slot lookups - Propagate values from predecessor into the linear block - Disabled reuse slot optimization - Keep `LuaNode::val` check for nil when optimizing `CHECK_SLOT_MATCH` - Implemented IR translation of `table.insert` builtin - Fixed mmap error handling on macOS/Linux # Tooling - Used `|` as a column separator instead of `+` in `bench.py` - Added a `table.sort` micro-benchmark - Switched `libprotobuf-mutator` to a less problematic version
Rendered