[erlang-questions] The is_record() guard

Bjorn Gustavsson bgustavsson@REDACTED
Tue Jul 28 09:07:26 CEST 2009


On Sat, Jul 25, 2009 at 10:39 PM, Steve
Davis<steven.charles.davis@REDACTED> wrote:
> Hi Bjorn,
>
> Definitely the approach suggested by Oscar shows much better numbers in
> fprof...
>
> I also see other cases where functions that filter arguments using guards
> appear to be (quite a bit) less efficient than direct matches on the
> arguments.
>
> Would it be fair to say that, where possible. pattern matching function
> arguments is in general more efficient than using guards?

Yes.

There is a section in the Efficiency Guide

http://erlang.org/doc/efficiency_guide/functions.html#6.1

that gives some insight into why guards may be inefficient (and also
shows an example where pattern matching without guards also
can be inefficient).

/Bjorn

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB


More information about the erlang-questions mailing list