[erlang-questions] Any wisdom to offer on "tagged return values"

Ulf Wiger <>
Wed May 6 17:37:08 CEST 2009

Joe Armstrong wrote:
> I would always prioritize clarity over efficiency, unless your code
> just has to be blindingly fast - so you might break this rule if you
> want to write faster but less clear code.

Luckily in this case, using fetch() when appropriate results
in code that is both faster and clearer.  ;-)

One can achive reasonably similar clarity by using

{ok, Value} = dict:find(...)

But doing so, means opting out of composition
(at least /convenient/ composition.)

Yesterday, as I was trying to figure out why edoc
crashed when trying to write a processed file to disk,
I wrote the following in the shell:

31> string:chr(tl(v(23)),8211).
32> string:substr(tl(v(23)),1230,20).
33> [45,75,101,121,32,112,97,105,114,32].
"-Key pair "

(The character following looked like ~ in emacs, but
became ASCII 8211 in the output, which io:put_chars() had
issues with.)

Not exactly revolutionary, nor especially elegant, but
it's extremely convenient to be able to chain functions
together without having to insert unwrapping code.

Ulf W

Ulf Wiger
CTO, Erlang Training & Consulting Ltd

More information about the erlang-questions mailing list