-
Notifications
You must be signed in to change notification settings - Fork 26
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
const overload accepting a closure for memoized lazy evaluation #32
Comments
This would be very much in the spirit of Haskell, since Haskell is lazily-evaluated by default. |
The semantics of I think escaping autoclosures are an anti-feature, and their use should be discouraged. If you want to support lazy evaluation, accept an explicit closure. |
That’d look like so: fooBarQuux.analysis(
ifFoo: const(0),
ifBar: const { ++x },
ifQuux: { $0 + $1 }) Yeah, I agree—that’s much less problematic. |
It’s hardly a constant unless it memoizes as well. I think that lines up nicely with this. |
I think
const
might be more useful if it were marked as@autoclosure(escaping)
. As it is, you can’t use it for any kind of effectful case analysis because effects occur regardless of the branch taken, which defeats the purpose of using case analysis for effects.The text was updated successfully, but these errors were encountered: