In addition to implicit lambdas, also add implicit partial application for operator functions
See original GitHub issueBroken off of #36. From that issue:
@evhub: In addition to implicit lambdas as was implemented here, I think it would also be a good idea to add implicit operator functions using the
(? + 5)
syntax, which would be equivalent to(+)$(?, 5)
, since I think the former is a lot easier to read. Reopening this issue to add that syntax. @fredcallaway: I don’t love the idea of a special syntax restricted to operator expressions. Can you come up with a syntax that works cleanly for both(? + 5)
and(foo(?) + 5)
? For example, something like option 3 above. @evhub: @fredcallaway The syntax(-> _ + 5)
or(-> foo(_) + 5)
was already added and handles those use cases. The rationale for(? + 5)
is that it would generate a partially-applied operator function instead of a lambda, which is significantly better for pickling, casting to a str, profiling, etc. @evhub: Maybe the right solution is just to detect implicit lambdas of the form(-> _ + 5)
and automatically compile them to partially-applied operator functions, but that seems too implicit and weird to me, so I’m wary to do it.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
I would prefer some variation of Elixir’s syntax:
&(&1 + &2)
. Maybe substituting$
for&
since that’s already associated with partial functions.New proposed syntax is to use a single dot in place of the missing argument. The implicit partial must be contained in parentheses, just like operator functions, and the implicit argument can only be a single atom. Examples of valid syntax: