exclude function calls

Fredrik Thulin ft@REDACTED
Fri Mar 24 16:19:23 CET 2006

On Friday 24 March 2006 15:56, Yani Dzhurov wrote:
> Hi guys,
> Is it possible to exclude some particular function calls in function
> definition while compilation.

I think you should avoid compile-time determinations like these as much 
as possible. Use run-time checks to see if you should do A or B 
instead. With compile-time decisions you never really know what the 
compiled code will do if you for example enable or disable something in 
a configuration file. Was the code compiled to include functionality X, 
which could therefor be enabled, or not?

Untested, but here is a way to do it at compile time :

  -define(DOBAR, true).

  myfun() ->
      ?DOBAR andalso bar(),

or, with a function (want_to_do_bar()) that determines if bar() should 
be called or not :

  calling_function() ->
      DoBar = want_to_do_bar(),

  myfun(DoBar) ->
      DoBaz andalso bar(),

You get the idea.


More information about the erlang-questions mailing list