[erlang-questions] Overriding built-in functions in a module

Mikael Pettersson <>
Fri Jun 4 11:43:39 CEST 2010

Richard O'Keefe writes:
 > We need the following things:
 > 	(1) If a function f/n is defined in a module,
 > 	    then any calls to f/n without a module prefix
 > 	    refer to THAT definition.
 > 	(2) The warning message for a definition of such
 > 	    a function should not say that it is defining
 > 	    a BIF but that it is defining a function with
 > 	    the same NAME as a BIF, e.g.,
 > 	./foo.erl:6: Warning: there is a BIF called spawn/1;
 > 	    to use the BIF you will need an erlang: prefix.
 > 	(3) Such warnings are useful, but sometimes it is
 > 	    intentional, so a directive such as
 > 	    -private([spawn/1]).
 > 	    would be useful to silence the warning while giving
 > 	    human readers (and the compiler!) adequate notice.
 > 	    (Amongst other things, in a code review, it is easier
 > 	    to grep for -private than to gather compiler warnings.)
 > I'm sure I've seen a proposal like this before, so I haven't written
 > up an EEP for it yet.

FWIW, I agree with all 3 points.  It would bring Erlang one step
closer to a saner set of scoping rules.  Having auto-imports
override local definitions is just plain wrong.

More information about the erlang-questions mailing list