-
Notifications
You must be signed in to change notification settings - Fork 449
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
Request for @functionExpression attribute to opt-out from arrow functions #7061
Comments
Doesn't We also have |
I'll check |
I've been exploring this for a bit. rescript-schema seems to be a somewhat special case. I believe most apps have a more explicit and idiomatic solution for binding context without relying on JS ReScript's It wouldn't be hard to implement for plain functions either, since there are already primitive implementations, but it would be inherently an unsafe way to write code, so even if we add it, it should be marked as an "unsafe" feature. |
Agreed. It is important that we get |
It seems like there's a lot of My suggestion is to expose a primitive API instead of attributes. We already have the necessary implementations; Js.Unsafe.thisCall((this, arg1, arg2) => {
...
})
// -> (('this, 'a, 'b) => 'result) => (('a, 'b) => 'result) |
|
Should we document this somehow? |
After the PR #6945 function expressions were changed to arrow functions to improve readability and bundle-size. But it also broke
this
andarguments
binding to the function context, which could be accessed via%raw("this")
when needed for some advanced logic.I need it for
rescript-schema
, so I think introducing an attribute@functionExpression
to opt-out from arrow functions would be a good solution.The text was updated successfully, but these errors were encountered: