5 ms·
Joe's points are really good. This drives me crazy in Elixir: iex(1)> f = fn x -> x + 1 end #Function<erl_eval.6.82930912> iex(2)> f() (UndefinedFunctionEr
by rubyrescue 13y ago
Joe's points are really good. This drives me crazy in Elixir:
iex(1)> f = fn x -> x + 1 end
#Function<erl_eval.6.82930912>
iex(2)> f()
(UndefinedFunctionError) undefined function(stack trace trimmed...)
iex(2)> f.(1)
2
- devinus 13y agohttps://groups.google.com/forum/?fromgroups#!topic/elixir-lang-core/Zop_x5K85XE https://groups.google.com/forum/?fromgroups#!topic/elixir-la... This was José Valim's rationale on the mailing list. Once you understand what's involved, f.() begins to look like a pretty good compromise.
- jeremyjh 13y agoIts true, but Joe is also correct that this is going to be something people complain about for decades.
- lobster_johnson 13y agoPersonally I would rather leave the syntax disambiguation to the programmer when relevant, rather than enforcing a single, awkward-looking syntax for all cases.
- jallmann 13y agoThat kind of variable shadowing is a smell. The compiler should warn about it, and/or re-bind the local method as expected (possibly shooting programmer in the foot, but hey... that's why it's a smell, Don't Do It). Forcing an inconsistent syntax to handle one corner case seems like another smell in itself.