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

mats cronqvist masse@REDACTED
Sat May 2 23:50:36 CEST 2009


"Kevin" <q2h46uw02@REDACTED> writes:

> In the "programming rules" 
> http://www.erlang.se/doc/programming_rules.shtml#REF32551
>
>
> ---snip--------------------------------------
> Use tagged return values.

  My $0.02 is that this advice is, and always has been, hogwash. It is
  a rare function that can return several valid answers. So, the
  default should be to return a valid answer, i.e. one that can be
  used directly, or throw an error.

  My theory is that the people who wrote this "programming rule" were
  (good) C programmers, and thus felt a need to check if the value
  returned was ok before they dared use it.

>
>
> Ironically in the lists man page it says keysearch is deprecated in 
> favor of keyfind, which does exactly what the programming rules
> cautions against.
>
> keyfind(Key, N, TupleList) -> Tuple | false

  Indeed.

  mats



More information about the erlang-questions mailing list