This one seems a strong argument against this proposal or other alike: > Today, if use default arguments and for some reason I want to stop doing so, I can freely do it without breaking user code.
Thanks terça-feira, 9 de Julho de 2019 às 21:17:49 UTC+1, José Valim escreveu: > > 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é Valim* > www.plataformatec.com.br > Skype: jv.ptec > Founder and Director of R&D > > > On Tue, Jul 9, 2019 at 9:30 PM Mário Guimarães <mario.lui...@gmail.com > <javascript:>> wrote: > >> Hi, >> >> when a function is defined like >> >> def fun(a, b \\ 1, c \\ 2) >> >> there is no way to call it by omitting the second argument, that is, one >> must call >> >> fun(a, 1, c) >> >> The idea of this proposal is to support the calling idiom >> >> `fun(a, _, c)` >> >> as the equivalent of calling >> >> fun(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 <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/1f77d478-247b-4071-b55f-9d14e0140a82%40googlegroups.com >> >> <https://groups.google.com/d/msgid/elixir-lang-core/1f77d478-247b-4071-b55f-9d14e0140a82%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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/09a00459-2b87-44f0-8a36-3019cc701c6f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.