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

Bjorn Gustavsson bjorn@REDACTED
Mon Mar 10 14:31:10 CET 2008


G Bulmer <gbulmer@REDACTED> writes:

> > You should use bif; ubifs are only for guard BIFs.
> Thank you. That clears that up.
> 
> I would like to make the two predicates (is_dtrace_on/0 and
> is_dtrace_off/0 ) available in guard expressions.
> I have them in bif.tab as:
>    ubif erlang:is_dtrace_on/0
>    ubif erlang:is_dtrace_off/0
> 

Creating a new guard BIF is a lot harder than creating an ordinary BIF,
so I suggest you'll wait with doing that.

The reason for the difficulties is that guard BIFs are specially optimized and
each BIF that can be used in guard must have corresponding BEAM instructions;
the new instructions must be supported in both the compiler and the emulator.

/Bjorn
-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list