[erlang-questions] Trouble with Erlang's lenient comparisons

Håkan Mattsson hm@REDACTED
Wed Apr 13 13:16:21 CEST 2011

When you discourage one way of writing code and claim that another way
is better you ought to motivate why.


On Wed, Apr 13, 2011 at 12:36 PM, Kostis Sagonas <kostis@REDACTED> wrote:
> Gordon Guthrie wrote:
>> ...
>> Also check for bad input to functions by using guards like:
>> fun(A, B, C) when is_list(A), is_integer(B), is_record(C, recC) ->
> The following is a bit pedantic, but please do not offer use of the
> is_record guard (esp. the one with arity two instead of three) as advice to
> newcomers.  I suggest that you try to forget about this guard's existence;
> the only place where this guard is possibly needed is in or/orelse contexts.
> The above code is written better using pattern matching, as in:
>  fun(A, B, #recC{} = C) when is_list(A), is_integer(B) ->

More information about the erlang-questions mailing list