[erlang-questions] The is_record() guard

Bjorn Gustavsson <>
Sat Jul 25 12:45:29 CEST 2009


2009/7/23 Oscar Hellström <>:
> Hi Steve,
>
> You could also do it this way:
>
> transform(#rec_a{} = R) -> ... ;
> transform(#rec_b{} = R) -> ... ;
> ...

Yes, that is the recommended way to do it.

Not only will the matching in the function head be more efficient, but
the compiler
may also generate better code for further record operations in the
body of the function.

/Bjorn

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


More information about the erlang-questions mailing list