[eeps] Multi-Parameter Typechecking BIFs

Andras Georgy Bekes <>
Sun Feb 22 12:51:03 CET 2009

> What we want, of course, is to say that the *whole* triple
> satisfies a named condition.  And we can do that, right now,
> with macros.
> 	-define(mod_func_arity(M, F, A),
> 	    is_atom(M), is_atom(F), is_integer(A), A >= 0).
> 	f(...{M,F,A}...) when ?mod_func_arity(M,F,A) ->

If you really want to say that the *whole* satisfies a named condition, 
with some extra work you can write:
 	    is_atom(element(1,MFA)), is_atom(element(2,MFA)),   
            is_integer(element(3,MFA)), element(3,MFA) >= 0).

f(...MFA...) when ?mod_func_arity(MFA) ->

You *can* express an arbitarily complex pattern with a guard (without 
being less efficient than a pattern).

Of course if you also want to have M,F and A seprately:
f(...{M,F,A}=MFA...) when ?mod_func_arity(MFA) ->

To me it communicates more clearly that MFA as a whole is a 

I'm not stating that this is better than abstract patterns. Abstract 
patterns are better. Unfortunately, they don't exist (yet).


More information about the eeps mailing list