What's wrong with you? What planet are you from? Any functional language has this function. These are basic concepts of mathematics and functional programming. What a "slippery slope"? It's insane. This function just must to be here, that's all. The standard library has `fn x -> x end` everywhere. So if you didn't know, this thing has a name!
воскресенье, 14 июля 2019 г., 18:34:36 UTC+3 пользователь Chris Keathley написал: > > I understand that the desire from the core team isn't to add this. I'm OK > with that decision despite feeling like it would be a good addition That's > fine. > > But I do take issue with this "slippery slope" argument that adding > `identity` to Elixir would somehow open the door to numerous other > functions being added to Elixir. Which is silly. Because we aren't talking > about adding some untold number of functions to Elixir. We're talking about > `identity`. If the core team had decided that `identity` was worth having > in the language would we still not add it because later someone could add > the `snausages` function? No. Of course not. That's a nonsensical argument. > Improvements to the language should be considered on their own terms. > > On Sat, Jul 13, 2019 at 12:26 AM Sven Gehring <[email protected] > <javascript:>> wrote: > >> I definitely agree that it's better to import it from an additional >> module if need be. >> >> If we ignore the Metaprogramming parts, Elixir has a very easy Syntax and >> the &(&1) notation is one of the only non-intuitive things to learn. >> Compared to other languages, there are virtually no 'weird' syntax elements >> you have to 'just remember' when you start out, so I am actually in favor >> of teaching people this shorthand instead of hiding it from them. (It's >> really not THAT complicated) >> >> Also, as José said, you can always use "fn x -> x end", which is about >> the same length as "&identity/1" and also obvious in what it does. >> >> I don't think expanding the Kernel just for the sake of adopting concepts >> of similar ecosystems is worth it. >> >> Sven >> >> On Fri, Jul 12, 2019, 23:10 Rich Morin <[email protected] <javascript:>> >> wrote: >> >>> > On Jul 12, 2019, at 13:43, José Valim <[email protected] >>> <javascript:>> wrote: >>> > >>> > Filtering nils may be considered bad practice (i.e. why do you have >>> nils there?) >>> >>> I use them, on occasion, to support a "maybe" type. >>> >>> > ... it may be more readable to do with Enum.reject(&is_nil/1). >>> >>> Cool! I just replaced four instances of `Enum.filter(&(&1))` with >>> `Enum.reject(&is_nil/1)`. >>> FWIW, I'd love to see an annotated collection of suggested Elixir idioms >>> such as this one. >>> >>> -r >>> >>> -- >>> 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 [email protected] <javascript:>. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elixir-lang-core/C4BDFC3F-1646-4957-B814-0204D3B147A6%40gmail.com >>> . >>> 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 [email protected] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/CAFuVuxzkdQbPZaPHRWA6w13LE1jFZm-sgoxK8ToOkTag2_9AbA%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/elixir-lang-core/CAFuVuxzkdQbPZaPHRWA6w13LE1jFZm-sgoxK8ToOkTag2_9AbA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > Chris > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/aa6ad3d9-abc6-4afb-b153-26491d3cc6b4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
