Re: [elixir-core:8940] Re: [Proposal] identity function

2019-07-12 Thread Sven Gehring
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

Re: [elixir-core:8939] Re: [Proposal] identity function

2019-07-12 Thread Rich Morin
> On Jul 12, 2019, at 13:43, José Valim 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(_nil/1). Cool! I just replaced four instances of

Re: [elixir-core:8938] Re: [Proposal] identity function

2019-07-12 Thread José Valim
Filtering nils may be considered bad practice (i.e. why do you have nils there?) so I think it should be done explicitly. And it may be more readable to do with Enum.reject(_nil/1). Enum.group_by with identity by default has no purpose. You are only going to group the elements themselves. At best

Re: [elixir-core:8937] Re: [Proposal] identity function

2019-07-12 Thread Bruce Tate
:) all good. I do think that both & &1 and fn x -> x end and & &1 are both harder to scan than /1 as it's almost always better to name a concept for a beginner (or most anyone, for that matter). In my classes we often write an identity function as an intermediate teaching step because I can

Re: [elixir-core:8937] Re: [Proposal] identity function

2019-07-12 Thread Chulki Lee
This is exact reason I'm against adding it to Kernel :) I already have a code using "identity". What would it happen when I upgrade to new Elixir version having this feature?) Let's look at the list of functions/macros in Kernel and its description - https://hexdocs.pm/elixir/Kernel.html

Re: [elixir-core:8935] Re: [Proposal] identity function

2019-07-12 Thread José Valim
If the goal is teaching, then I think "fn x -> x end" beats both "/1" and "& &1" in terms of clarity, as identity itself is still a concept that needs to be explained. *José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R On Fri, Jul 12, 2019 at 7:18 PM Bruce Tate

Re: [elixir-core:8934] Re: [Proposal] identity function

2019-07-12 Thread Bruce Tate
> Why should we add this to Elixir core, instead of "extending" with module? I have been a big proponent of this for a long time because just about every code base uses the identity function and it's a barrier to those who would learn Elixir. Rather than import or call /1, most would just

Re: [elixir-core:8933] Re: [Proposal] identity function

2019-07-12 Thread José Valim
Generally speaking, I agree with Chulki Lee. I understand the value of the identity function. But the cons of adding it to Kernel is that we partially take the name away from everyone else, unless they unimport it, and ultimately the implementation of identity/1 is not doing much to wararnt this

[elixir-core:8933] Re: [Proposal] identity function

2019-07-12 Thread Chulki Lee
I'm happy to see Elixir adopting FP concept here ([identity function](https://en.wikipedia.org/wiki/Identity_function)), but I'm not sure it's good to add it to `Kernel` (as it's imported by default!) - or even in Elixir core. Why should we add this to Elixir core, instead of "extending" with

Re: [elixir-core:8932] Re: [Proposal] identity function

2019-07-12 Thread Alexey Nikitin
Any news here? @José Valim, let's do this. Almost everyone reacted to this with enthusiasm. It would be nice. Without this function elixir couldn't be a category :) Let's make elixir Lisp again! вторник, 2 июля 2019 г., 21:40:45 UTC+3 пользователь José Valim написал: > > Thanks Chris, it is