Redirecting functions calls ?

erlang@REDACTED erlang@REDACTED
Fri Apr 23 12:32:39 CEST 2004


> Is there a method to redirect the call of a function and execute
> another one instead.
> For exemple, lets assume 2 functions "foo" and "bar":
> 
> foo(X) ->
>  blablabla,
>  26.
> 
> bar(Y) ->
>  blablabla,
>  38.
> 
> When calling foo(10), I want to intercept this call and replace with
> bar(10).  Of course, the result of foo(10) is replaced by the one of
> bar(10).

Maybe I'm being too simplistic, as I don't really understand the
discussion that followed about the compiler bug, but wouldn't this do
what you want:

foo(10) ->
 bar(10);
foo(X) ->
 blablabla,
 26.

bar(Y) ->
 blablabla,
 38.

Robby




More information about the erlang-questions mailing list