-
Notifications
You must be signed in to change notification settings - Fork 396
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
Implement support for math.lerp #1608
Conversation
@@ -235,7 +235,7 @@ static uint8_t getBytecodeConstantTag(Proto* proto, unsigned ki) | |||
return LBC_TYPE_ANY; | |||
} | |||
|
|||
static void applyBuiltinCall(int bfid, BytecodeTypes& types) | |||
static void applyBuiltinCall(LuauBuiltinFunction bfid, BytecodeTypes& types) |
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.
(made this change to get exhaustive switch checks)
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.
Please remove the unflagged split changes to the definitions.
Splitting like we do for buffer and vector is ok, but splitting them further with a string builder approach isn't great to work with.
I would take duplication over it, however you might wait until after the Friday sync which removes one of the copies.
This change implements math.lerp RFC with C function definition, builtin function, builtin constant folding and type inference, and tests. The tests validate a few lerp properties by providing counter-examples for popular lerp implementations; the testing is of course not exhaustive, as exhaustive testing was done offline using fuzzing. Type definitions and codegen support will be implemented separately.
I don't quite see why that is the case - I think the approach as implemented in the original commit is a clean way to allow adding members separately in the future. I thought about splitting individual libraries entirely (with Additionally, there was a TODO comment "// TODO: there has to be a better way, like splitting up per library" which I recommend removing because after seeing this I decided I might as well do it this way. Regardless, I've reverted the type changes entirely and I will wait for Luau team to figure this out as well as add math.lerp definition using whatever flagging paradigm they prefer. |
Just to explain the reasoning from my side, I dislike how it's inconsistent between old and freshly added members. If there is an intent that after unflagging the string will be embedded into the "full" definition for a library, it means that unflagging is not trivial and gets harder to argue for unflagging PR safety internally. Having parts of the same construct
Copy-pasting big chunks of code has never been a problem for me ;)
We have started splits with |
Yes - that was the intent. I think it should be possible to argue that
I only did this this way because of how math.map was implemented fwiw, canonically in the past "throw if not enabled" approach was used more often I believe. |
This change implements math.lerp RFC with C function definition, builtin
function, builtin constant folding and type inference, and tests.
The tests validate a few lerp properties by providing counter-examples
for popular lerp implementations; the testing is of course not
exhaustive, as exhaustive testing was done offline using fuzzing.
Type definitions are implemented in a separate commit; to avoid havingto copy the entire surface two more times I've split the string into a minimal
set of components that can be spliced based on existing flags. I would expect
further splits to happen across library boundaries, but I avoided doing that to
simplify the patch. Let me know if you'd rather see this done, or if you'd rather
see the type changes in a separate PR.
Codegen support will be implemented separately: it requires new IR for conditional
selects to represent the desired logic without using a branch.