-
Notifications
You must be signed in to change notification settings - Fork 13.4k
#bind() macro #1581
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
This would also be an easy way to pass functions with incompatible argument modes to higher-order functions. |
I was thinking... I would perhaps like to go the opposite direction and make bind more special. The idea would be to omit the bind keyword, as in Scala. This would allow constructs like:
In an ideal world, we could even support things like "_ + " (which work in Scala). When you go that far, though, the tricky part is to decide where the bind boundary is... for example, is ".foo(_)" equivalent to "bind .foo()" or "bind _.foo(bind _)"? Both make sense (Here, Still, writing "my_vec.foldl(0, _ + _)" is pretty nice. Anyway, the way I thought to implement this kind of thing (and to rewrite bind) is basically to have an AST node similar to the one which represents "{||...}" closures right now. So we'd get the inference of what kind of closure it is "for free". |
#1649 discusses my proposal. It also discusses a change to the semantics of |
Is this still relevant? I think it is not, given the discussion in #1649. |
We can probably take advantage of lambda-blocks' type inference (may need some tweaking still to make it work in more situations) to create a bind macro or extension that works for all function types, then get rid of bind.
The text was updated successfully, but these errors were encountered: