[erlang-questions] lists:reverse/1 as a built-in function

Robert Virding <>
Fri Jan 12 11:17:07 CET 2007


I think the main problem here is semantic, what is meant by a built-in 
function, BIF.

BIFs have always meant things that were part of the Erlang language but 
didn't have a special syntax; they looked like "normal" function calls. 
How they are implemented is completely irrelevant! Spawn, link, size etc 
are all just as much a part of the language as ! and receive, but they 
have no special syntax, they are BIFs. Both spawn/3 and spawn/4 are 
BIFs, spawn/3 is implemented in C while spawn/4 is implemented in 
Erlang. The unfinished Erlang standard addresses the use of the term 
BIF. Unfortunately the reference manual is not clear on this point.

So with this in mind it is not really strange that BIFs are 
auto-imported, and have priority over "normal" functions defined in 
modules; they are part of the language. It is perhaps unfortunate that 
we allowed definition of functions with the same name and arity as the 
auto-imported ones.

What is a bit of a mess is that some BIFs are auto-imported while some 
you can only reach by explicitly using the module name erlang. Well all 
exist in the module erlang but for some this is implicit. Unfortunately 
there seems to be no clear logic why some BIFs are auto-imported and 
some need to be prefixed with erlang. This is an old problem.

The meaning of BIF was not really a problem until functions which are 
clearly not BIFs were implemented in C for efficiency, functions like 
append and reverse. These functions are perfectly logically part of the 
module lists.

What is needed is a new term to describe functions which are implemented 
in C in the emulator which are not BIFs.

Robert



More information about the erlang-questions mailing list