Should we rename the args/terminology used in Enum module?

49 views
Skip to first unread message

eksperimental

unread,
Sep 25, 2015, 3:28:23 AM9/25/15
to elixir-l...@googlegroups.com
Reading the documentation for Enum.into/2,
gave me the wrong idea of what the function does.

http://elixir-lang.org/docs/master/elixir/Enum.html#into/2

The summary reads:
into(collection, list): Inserts the given enumerable into a
collectable.

which made me thing that list(the enumerable) will be inserted into
collection (the collectable)

the first example made sense:
iex> Enum.into([1, 2], [0])
[0, 1, 2]

but the second one didn't
iex> Enum.into([a: 1, b: 2], %{})
%{a: 1, b: 2}

Why inserting an empty map into a list, will convert the list into a
map.

When I read the specs, I understand there was something wrong.

Specs:
into(Enumerable.t, Collectable.t) :: Collectable.t

Alright, that's easy to fix. But then going reviewing the documentation
for the module I see the subject of the functions named "collection" is
always used to refer to an Enumerable, which is what the Enum module is about.

So i propose to rename the "Enum" mode to be called "Collect"!

nah.. just a bad joke ;-)

so.. what I think we need to do is rename the "collection" arguments to
"enumerable", and every reference to them.

and use collection only for collectables, such as in the Enum.into case.

WDYGT?

José Valim

unread,
Sep 25, 2015, 3:57:56 AM9/25/15
to elixir-l...@googlegroups.com
If we rename "collection" to "enumerable", then "collectable" should be kept as "collectable" for consistency, since we are naming things after the protocols they implement.



José Valim
Skype: jv.ptec
Founder and Director of R&D


--
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/20150925142813.280392ce.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.

eksperimental

unread,
Sep 25, 2015, 4:08:13 AM9/25/15
to elixir-l...@googlegroups.com
true! that makes absolute sense
;-D

On Fri, 25 Sep 2015 09:57:31 +0200
José Valim <jose....@plataformatec.com.br> wrote:

> If we rename "collection" to "enumerable", then "collectable" should
> be kept as "collectable" for consistency, since we are naming things
> after the protocols they implement.
>
>
>
> *José Valim*

eksperimental

unread,
Sep 26, 2015, 6:49:41 AM9/26/15
to elixir-l...@googlegroups.com
I will submit a PR soon then

On Fri, 25 Sep 2015 09:57:31 +0200
José Valim <jose....@plataformatec.com.br> wrote:

> If we rename "collection" to "enumerable", then "collectable" should
> be kept as "collectable" for consistency, since we are naming things
> after the protocols they implement.
>
>
>
> *José Valim*
Reply all
Reply to author
Forward
0 new messages