[erlang-questions] Help: What's the correct way to add new BIFs?

G Bulmer gbulmer@REDACTED
Thu Mar 6 18:33:57 CET 2008

I want to add a few new BIFs to erts for some DTrace experiments, and  
I'd like some pointers/advice.
(They may not end up in the solution, so please don't panic yet:-)

Is there a document which describes the correct approach? (I thought  
I'd seen it a few months ago, but I, google and spotlight can't find  
it :-(

The questions I'd like some help/advice with are:
1. I read (in bif.tab) that ubifs are bif's without trace wrappers. Is  
this a critical decision, or is it okay to use ubifs, and decide later?

2. In the syntax description in bif.tab, its says:
<bif-decl> ::= "bif" <bif> [<C-name>] | "ubif" <bif> [<C-name>]
<bif> ::= <module> ":" <name> "/" <arity>

Actual examples are:
ubif erlang:abs/1
ubif 'erl.lang.number':abs/1		ebif_abs_1
bif erlang:binary_to_term/1	
bif 'erl.lang.binary':to_term/1		ebif_binary_to_term_1

This example seems to define the same bif twice. What is this doing  
really? What is the atom 'erl.lang.number' or 'erl.lang.binary' for?
(I've read the make_tables script, but my perl is bad, so it isn't  
clearto me, sorry.)

Small point, I read the the syntax productions as <C-name> is  
optional, but:
bif erlang:atom_to_list/1
bif 'erl.lang.atom':to_string/1		ebif_atom_to_string_1 atom_to_list_1

has two. I think the syntax in the bif.tab comment maybe should read:  
<bif-decl> ::= "bif" <bif> {<C-name>} | "ubif" <bif> {<C-name>}
as {...} is conventionally 0 or more.

3. To be clean and tidy, I feel I should put our new bifs in a new set  
of source files (rather than mx them into the existing bif source  
Are there some naming conventions I should follow to align with the  
OTP team?
I assume that the new bifs should be put in a section at the end of  

Thanks in advance for pointers/advice.

G Bulmer

More information about the erlang-questions mailing list