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

Richard O'Keefe <>
Wed Jun 9 04:05:55 CEST 2010


On Jun 4, 2010, at 9:29 PM, Attila Rajmund Nohl wrote:

> 2010/6/4, Richard O'Keefe <>:
>>      6  spawn(F) -> F(41).
>>
>> where we're expecting foo:bar() to return 42.
>> erlc reports
>>
>> /foo.erl:4: Warning: call to spawn/1 will call erlang:spawn/1; not
>> spawn/1 in this module
>>   (add an explicit module name to the call to avoid this warning)
>> ./foo.erl:6: Warning: defining BIF spawn/1
>> ./foo.erl:6: Warning: function spawn/1 is unused
>>
>> The second message is clearly WRONG:  this _can't_ be defining the
>> built-in function erlang:spawn/1 because this isn't the erlang:
>> module.
>
> I think that second message is right.

It is right that there is a message.
What the message literally says is completely untrue.

> The message is not about
> erlang:spawn,

Maybe not, BUT IT SAYS THAT IT IS!  It doesn't mention
'erlang:', true.  But it does say "BIF", and this function
definition, whatever else it is, is NOT a BIF definition.

The error message should say something like
'local definition clashes with pre-R14A auto-imported function.'

Just at the moment, with a small class of students who've just
met Erlang, I have become very sensitive to the question of when
error messages do more harm than good.



More information about the erlang-questions mailing list