-
Notifications
You must be signed in to change notification settings - Fork 464
Remove lazy keyword #6241
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
Comments
By what metric was it "not commonly used or known"? I have ~50 usages across a decent size codebase. Not a ton, I'll admit, but still. I've done manual thunking for years in JS, it was nice to have explicit syntax for it. |
Can you show a usage example, with and without |
The linked TypeScript code is using options, with the thunk representing the "if none" value but we want to avoid the computation in the "some" case. Basically the same as a lazy. It might help to see the definition. As a replacement for
A simple example is when rendering the editor in a test, we have an optional schema and if one isn't provided we create a default.
And yes, absolutely, we could do |
Thanks for the explanation! Just to give a fresh eyes perspective on it: I think the clarity here comes mostly from the function being named It's not hard to imagine a hypothetical scenario where a lazy value is used by several calls to |
ah yes, I do understand the difference now that you mention it. It's hard to see in our code whether we depend on the caching nature of lazy values or just leverage them as single-use thunks as in my example. I suppose as long as we still have the |
It seems the
lazy
keyword inherited from OCaml is a not commonly used or known in ReScript.We should consider removing this keyword, it is always possible to use
Lazy.from_fun
instead if one wants to use OCaml'sLazy
module.And possibly a
Lazy
module with a more ReScript-like API could be added to Core.The text was updated successfully, but these errors were encountered: