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

Richard O'Keefe <>
Tue Nov 27 22:23:48 CET 2012


On 27/11/2012, at 9:34 PM, 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()

_Please_ don't use SomeSet:to_list().
When you write set:to_list(Some_Set) it is crystal clear what's
happening and if due to a bug somewhere Some_Set happens not to
be a well-formed set the error will be caught.
If you were to write Some_Set:to_list(),
*I* would not know what was going to happen without tediously
tracing through the code to find out what kind of value Some_Set
was; the *compiler* would not know without similar tracing;
cross-referencing wouldn't help nearly so much; and above all
an error might not be noticed as quickly at run time or even at
all.

Erlang is not an object-oriented language, by design.

Verbosity is a price that should only be paid if it buys you
something worth having.  I suggest that easier understanding,
better type checking, and better navigation are worth having.




More information about the erlang-questions mailing list