I realize it might be controversial, but I truly enjoy short form lambdas in any language I touch and Elixir is one of them. Yet I think there's a couple of use cases that are uncovered. One is when you need to encode a zero argument lambda returning a value and the second one is when there are more arguments than actually used:
iex(1)> &(&2 + 1) error: capture argument &2 cannot be defined without &1 (you cannot skip arguments, all arguments must be numbered) └─ iex:1 ** (CompileError) cannot compile code (errors have been logged) iex(1)> &(1) error: capture argument &1 must be used within the capture operator & └─ iex:1 ** (CompileError) cannot compile code (errors have been logged) I think both of these cases would be handled if we let explicitly defining the arity of lambda: &2(&2 + 1) or something like that. Since nested lambdas are not allowed anyways, this should work (unless I'm missing something). And we'd assume if there's no access to the variables, it would be a zero argument function, so &(1) would work too. This should be fundamentally possible, since I can do this: iex(9)> fn () -> :ok end #Function<43.105768164/0 in :erl_eval.expr/6> iex(10)> fn (_a, b) -> b * 2 end #Function<41.105768164/2 in :erl_eval.expr/6> So I assume it boils down to parsing? Either way, I'd love to see that in Elixir and I'm willing to contribute some time to get it implemented if the community approves it. -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/b4d29426-fc47-479e-beb9-69676684aae2n%40googlegroups.com.