Skip to content
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

Lower standalone dotted infix operators as anonymous functions #34156

Closed
mbauman opened this issue Dec 19, 2019 · 4 comments · Fixed by #37583
Closed

Lower standalone dotted infix operators as anonymous functions #34156

mbauman opened this issue Dec 19, 2019 · 4 comments · Fixed by #37583
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:broadcast Applying a function over a collection

Comments

@mbauman
Copy link
Sponsor Member

mbauman commented Dec 19, 2019

I could've sworn we already had an issue tracking this, but I couldn't find it. In short, I'd love to have support for standalone (.+) and friends to lower to (args...)->(+).(args...). This would enable their use in higher order functions and generally make them more useful.

They currently parse as identifiers — and can be assigned to! — so this would be a breaking minor change.

@mbauman mbauman added compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:broadcast Applying a function over a collection labels Dec 19, 2019
@ararslan
Copy link
Member

Would it be weird to be able to do e.g. map(.+, a, b) but not map(f., a, b) in general?

@JeffBezanson
Copy link
Sponsor Member

It would be nice, at least, to have a non-weird 😄 syntax for that, e.g. broadcast(f). Unfortunately that is already defined to do f(), but that is fairly useless.

@StefanKarpinski
Copy link
Sponsor Member

Maybe broadcasted(f)?

@mbauman
Copy link
Sponsor Member Author

mbauman commented Jan 3, 2020

Unfortunately Base.broadcasted(f) is simply the lazy version of broadcast(f). It's similarly varargs and, when materialized, it also means f().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:broadcast Applying a function over a collection
Projects
None yet
4 participants