Redirecting functions calls ?

Sean Hinde sean.hinde@REDACTED
Fri Apr 23 11:40:34 CEST 2004


Hi,

I have heard that this is the sort of obfuscation that Java and C++ are  
designed for. For Erlang there is an obvious optimisation which will  
remove the need for what you want ...

Otherwise I don't think so.

Sean

On 23 Apr 2004, at 10:57, yerl@REDACTED wrote:

> Hi Sean,
>
> Incredible bug!! Is it fixed?
> The test/1 guard (i.e. when fred) is responsible of the error.
> Any onther idea to achieve what I want?
>
> Lot of thanks
> Younès
>
>
> ----Message d'origine----
>> Copie à: erlang-questions@REDACTED
>> De: Sean Hinde <sean.hinde@REDACTED>
>> Sujet: Re: Redirecting functions calls ?
>> Date: Thu, 22 Apr 2004 23:18:18 +0100
>> A: yerl@REDACTED
>>
>> Hi,
>>
>>
>> On 23 Apr 2004, at 00:39, yerl@REDACTED wrote:
>>
>>> Hi All,
>>> 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).
>>>
>>> Can anyboby help me!
>>
>> Actually this is almost possible - I discovered a compiler bug just
>> today:
>>
>> -module(compiler_bug).
>> -export([test/1, wow/1]).
>>
>> test(A) when fred ->
>>     {ok, A}.
>>
>> wow(A) ->
>>     wow.
>>
>> This compiles fine. Trying this out:
>>
>> 175> compiler_bug:test(1).
>>
>> =ERROR REPORT==== 22-Apr-2004::23:11:45 ===
>> Error in process <0.1000.0> on node 'eradius@REDACTED' with exit
>> value:
>> {function_clause,[{compiler_bug,wow,[1]},{erl_eval,do_apply,5},{shell, 
>> ev
>> al_loop,2}]}
>>
>> ** exited: {function_clause,[{compiler_bug,wow,[1]},
>>                              {erl_eval,do_apply,5},
>>                              {shell,eval_loop,2}]} **
>>
>> I haven't managed to make it correctly call wow(1), but the error
>> report suggests that my call to test/1 did indeed result in a call to
>> wow/1
>>
>> :-)
>>
>> Sean
>>
>>
>




More information about the erlang-questions mailing list