I think of & as those in that order of preference: &<identifier>/<integer> - local function reference &<simple-expression> - lambda definition where <simple-expression> : <function-call> | <literal> | (<complex-expression>)
So &1 = fn -> 1 end &num/2 = fn a, b -> num(a, b) end And of course we don't need even the existing syntax as "this would be done to save just a handful of characters". On 15 February 2019 22:10:04 GMT+11:00, "José Valim" <jose.va...@plataformatec.com.br> wrote: >Furthermore there are intrinsic ambiguities: > >For example: > >&1 > > >Is that a function that returns 1 or is it a user error which forgot >the >outermost &? > >And this example: > >&num/2 > > >Is that num divided by 2 or an attempt to capture the num function of >arity >2? > >So the reason why the capture operator requires at least one >(consecutive) >argument is to make the code clearer. And sure, the compiler could >solve >those, but the ambiguity will always be there for users reading the >code. > >*José Valim* >www.plataformatec.com.br >Skype: jv.ptec >Founder and Director of R&D > > >On Fri, Feb 15, 2019 at 12:05 PM Andrea Leopardi ><an.leopa...@gmail.com> >wrote: > >> Hey Mario, >> >> The capture operator today already has a few forms (arity or >arguments) >> and I think it would be better to keep it simple and not add more >specific >> behaviors, especially considering this would be done to save just a >handful >> of characters. >> >> Andrea >> >> On Fri, 15 Feb 2019 at 11:56, Mário Guimarães < >> mario.luis.guimar...@gmail.com> wrote: >> >>> Where is >>> >>> fn () -> M.fun("value") >>> >>> it should be >>> >>> fn () -> M.fun("value") end >>> >>> or >>> >>> fn -> M.fun("value") end >>> >>> >>> >>> quinta-feira, 14 de Fevereiro de 2019 às 16:46:18 UTC, Mário >Guimarães >>> escreveu: >>>> >>>> Hello, >>>> >>>> Elixir could support function captures without the need for any >>>> argument, so that of instead of writing >>>> >>>> fn () -> M.fun("value") >>>> >>>> end one could write >>>> >>>> >>>> &M.fun("value") >>>> >>>> Today the later returns an error like >>>> >>>> ** (CompileError) iex:28: invalid args for &, expected an >expression in >>>> the format of &Mod.fun/arity, &local/arity or a capture containing >at >>>> least one argument as &1, got: M.fun("value")) >>>> >>>> Thanks >>>> 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-lang-core+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> >https://groups.google.com/d/msgid/elixir-lang-core/a8c88a03-3a3a-4161-bbe4-52f24e1592e9%40googlegroups.com >>> ><https://groups.google.com/d/msgid/elixir-lang-core/a8c88a03-3a3a-4161-bbe4-52f24e1592e9%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> >> Andrea Leopardi >> an.leopa...@gmail.com >> >> -- >> 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/CAM9Rf%2BKJDRioz6hpw5-_ByvTNeTd8X-ecMFFXJyJrSsnzi4PXQ%40mail.gmail.com >> ><https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BKJDRioz6hpw5-_ByvTNeTd8X-ecMFFXJyJrSsnzi4PXQ%40mail.gmail.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/CAGnRm4%2B6g5ZBCVyKT_o-O7eeHrG0RetNy64%2BxSN_k8QXTv4Duw%40mail.gmail.com. >For more options, visit https://groups.google.com/d/optout. -- Kind regards, Dmitry Belyaev -- 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/9C3AFE2E-6DF0-42E3-89D0-1CD5D3726E71%40gmail.com. For more options, visit https://groups.google.com/d/optout.