[erlang-questions] tuple modules, or Set:to_list() is official?

Loïc Hoguin <>
Tue Nov 27 10:34:48 CET 2012

On 11/27/2012 09:34 AM, Motiejus Jakštys wrote:
> Hello,
> I just wrote sets:to_list(SomeSet), and stopped for a second. So does
> this[1] really mean that these are equivalent, supported, and both right
> ways to do the same work?
>      set:to_list(SomeSet)
>      SomeSet:to_list()
> Is there an underlying message somewhere "if you can, you not
> necessarily should?"
> (I am aware that dialyzer will not understand me until R16, but this
> doesn't concern me now).
> Answer "go to hell" is also good. That way I will learn that some people
> do hate it and will, and I don't mind programming in subset of Erlang
> for the sake of common good (the same way I appreciate my colleagues
> keeping 80 character line limit just for me).

I still don't like it. It looks like you call a /0 function when it's in 
fact a /1.

How do you distinguish this?

SomeSet:to_list() %% SomeSet = set
SomeSet:to_list() %% SomeSet = {set, [stuff]}

It's fine until you mess up somewhere.

Another case, if you mistakenly save {ok, SomeSet} to some variable, you 
end up calling the module ok with a function of arity different of what 
you intended. That'll do wonder for error messages readability.

This syntax makes no sense.

Loïc Hoguin
Erlang Cowboy
Nine Nines

More information about the erlang-questions mailing list