[erlang-patches] supervisor patch for parameterized modules

Serge Aleynikov <>
Wed Oct 1 13:43:40 CEST 2008

Actually there's a bug in the patch below as the guards are not applied 
properly.  This will be treated as a valid function:

	{{new, X}, "abc", 1234}

You need to break these into two separate matches because the ';' guard 
delimiter has precedence over ',':

validFunc({M, F, A}) when is_atom(M), is_atom(F), is_list(A) -> true;
validFunc({M, F, A}) when is_tuple(M), is_atom(element(1, M))
                         , is_atom(F), is_list(A) -> true;

Joseph Wayne Norton wrote:
> The supervisor application does not support children that are 
> implemented by a parameterized module.  The following change permits a 
> tuple for a child spec.  Is this behavior by design (possibly for code 
> reloading purposes)?

*** ./otp_src_R12B-4/lib/stdlib/src/supervisor.erl.orig		2007-06-11 
21:52:46.000000000 +0900
--- ./otp_src_R12B-4/lib/stdlib/src/supervisor.erl	2007-09-19 
17:57:17.000000000 +0900
@@ -781,7 +781,7 @@

  validName(_Name) -> true.

-validFunc({M, F, A}) when is_atom(M),
+validFunc({M, F, A}) when is_atom(M); is_tuple(M),
                            is_list(A) -> true;
  validFunc(Func)                      -> throw({invalid_mfa, Func}).

More information about the erlang-patches mailing list