def fun(a, b \\ 1, c \\ 2)--
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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1f77d478-247b-4071-b55f-9d14e0140a82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You haven't elaborated on why this would be a good feature, which problems it solves, and what are the alternatives.In any case, the issue with this feature is that it couples the caller with an implementation choice of the callee. Today, if use default arguments and for some reason I want to stop doing so, I can freely do it without breaking user code. If we add this syntax, the default arguments become official part of the function API, which makes it harder for code to change in the future. It looks to me like very bad coupling.If you have multiple default arguments and you want to skip one of them, as shown in the proposal, odds are that you should be using options / keyword lists instead (i.e. named arguments instead of positional ones).José ValimSkype: jv.ptecFounder and Director of R&D
On Tue, Jul 9, 2019 at 9:30 PM Mário Guimarães <mario.lui...@gmail.com> wrote:
Hi,--when a function is defined likedef fun(a, b \\ 1, c \\ 2)there is no way to call it by omitting the second argument, that is, one must callfun(a, 1, c)The idea of this proposal is to support the calling idiom`fun(a, _, c)`as the equivalent of callingfun(a, 1, c)
That is, in a function call the underscore would mean "use the default value for the argument at this position".I remembered that this could be an interesting syntax addition to Elixir, hence this post.I don't know the implications or difficulty of implementing this, besides seeing this as a non-breaking change proposal.Best regards,Mário
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-l...@googlegroups.com.