[erlang-questions] Style wars: junk comments

Wed Sep 12 13:25:40 CEST 2012

> Just in case that semantic categories means that functions that belong
> together are placed together, I solve that kind of problem by having the
> same prefix on functions that deal with the same thing.

Squeak 4.1:
 'Collections-Unordered'      "A group of related classes"
   Dictionary                 "A particular class"
     enumerating              "A group of methods that all iterate"
       #associationsDo:       "iterate over (key->values) pairs"
       #associationsSelect:   "select subset of (key->value) pairs"
       #collect:              "map, function applied to values only"
       #do:                   "iterate over values"
       #keysAndValuesDo:      "iterate over keys and values"
       #keysDo:               "iterate over keys"
       #select:               "select maplets looking just at values"
       #valuesDo:             "another name for #do:, at least here"

Giving these methods a common prefix would very definitely
reduce readability.

Take a look at lists.erl some time.

keysort/2 is in one place.
It calls keysort_1/5 and keysplit_1/8.
Now keysort_1/5 follows right after;
it calls keysplit_1/8 and keysplit_2/8,
which are 1000 lines and 1030 lines
away respectively.

That kind of nonsense is why I want tightly
coupled functions close together, regardless
of name, if that is possible.

This is actually a place where I would
do one of two things:
split keysort/2 and its support functions
into a separate module, and re-export it,
or split keysort/2 and its support functions
into a separate file, and -include it.

More information about the erlang-questions mailing list