Luau Recap: October 2023

I find myself using ceil a LOT. In terms of languages implementing floored-division, it usually comes by default due to dividing an integer resulting in a floored result no matter what, and very rarely exists as an operator all on it’s own. So already, Luau implementing a specific operator to perform a floored-division is quite odd, so a ceiled-division wouldn’t really mean much. Let me list some reasons why this new operator would be helpful:

  1. Improved consistency and readability. The ceiling-division operator would be a standardised technique to perform a division operation that rounds up, rather than implementing a harder-to-read and understand line of arithmetic such as local x = -(-10 // 3) or local c = a // b + 1. Additionally, The existence of a flooring-division operator should be accompanied by a ceiling-division operator for consistency of practice.

  2. Avoiding explicit rounding functions. A ceiling-division operator would allow us to avoid using an explicit function such as math.ceil, and a similar reason would’ve been used for the flooring-division operator to avoid use of math.floor.

  3. Ceiling-division would align with Luau’s goals and design principles by providing a convenient and expressive feature to us.

In conclusion to this evidence, I think we, the developers, would benefit greatly from implementation of the ceiling-division operator.

/s

I mean you can do that although the edge case of flooring a whole number would be inaccurate although chances are you won’t get a whole number as a result in an operation that requires floor division

1 Like

Vector3 is a type that’s built-in into Luau VM, so it gets support first.
Vector2 and others have to be implemented separately in Roblox codebase, so they will come later.

Could be interesting to have a math.round() that round floor or ceil if the number is higher or lower then .5

That would be pretty cool, I agree.

https://create.roblox.com/docs/reference/engine/libraries/math#round

4 Likes

Are luau class declarations still on the roadmap? It’s been mentioned a few times a couple years ago, I’ve been trying to make use of typed luau for OOP, but it results in massive bloat, incompatibility with things like inheritance, lots of other issues that make it very difficult to use. Some sort of class syntax would solve all of these issues.

4 Likes

i’ve been hoping for this for a long time. now that arseny is leaving i’m even less confident it’ll come soon. can’t we just have syntactic sugar for oop?

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.