[erlang-questions] Any wisdom to offer on "tagged return values"
Wed May 6 10:41:53 CEST 2009
"Richard O'Keefe" <ok@REDACTED> writes:
> On 6 May 2009, at 4:27 am, Ulf Wiger wrote:
>> Also, functions that return tagged values don't compose well.
>> I've found that I don't use composition that much in my code,
>> and I think it's something that one can certainly go overboard
>> with. The problem that frequent case matching clutters up the
>> code is a bigger issue, IMHO.
> When you are writing code for a specific use,
> there's a rule of thumb that I use.
> I think it makes sense for library code too.
> Basically, it's "let it crash".
> Spelling it out,
> - if the immediate caller of a function will know what to
> do with the "exceptional" result, return a tagged value
> - if it won't, so that the code would be cluttered up with
> stuff that just passes the buck, throw an exception.
> For library code, you have to make (informed) guesses about
> whether the caller is _likely_ to have anything useful it
> can do with the "exceptional" result.
Now, the start of this thread was that Kevin was sceptical re this
Programming Rule; "Use tagged return values." I think it's safe to say
that he's right. Following this rule will make you write sub-optimal
More information about the erlang-questions