Erlang standard library quirks

James Hague <>
Sun Jan 29 04:05:16 CET 2006


I realize that the Erlang libraries are essentially set in stone, but
I've built up a list of little quirks I repeatedly run into, and I
thought I'd pass it along.  None of these are serious.  They're simply
things I have to stop and think about when I need to use particular
functions, whereas in a perfect world they'd be simple and automatic.

1. sets/ordsets/gb_sets and the equivalent modules for dictionaries. 
There are advantages and disadvantages to each, yes, but I always end
up looking at each of them in the docs first before remembering which
one I want.

2. The io and file modules.  You open a file with file:open.  You read
lines out of it with io:get_line.  I understand the architectural
reasons behind the distinction, but that doesn't mean it isn't
peculiar from just-writing-code point of view.

3. The prompt being part of io:get_line.  I always want to say
io:get_line(IoDevice), forgetting that the single parameter version
reads from stdin and the parameter is the prompt (the correct call is
io:get_line(IoDevice, '').  Feels like io:prompt_for_line(Prompt)
should be a separate function, as prompts are rare.

4. The most common things I do with ets are create private sets and
bags (and the ordered and duplicate variants), to the point where I
have utility functions called new_set, new_bag, new_ordered_set and
new_duplicate_bag, none of which take parameters.  This keeps me from
having to remember all the defaults and options for ets:new.  Too bad
these aren't part of the standard.

What standard library quirks bug you?



More information about the erlang-questions mailing list