Reflection in Erlang.

Héctor Rivas Gándara keymon@REDACTED
Wed Jan 26 16:50:36 CET 2005


Hi, 

One year ago somebody asked for a way to obtain info on a loaded module.
The response were module_info/0 and module_info/1 funtions.

My question now is if its posible to dinamicly impersonate  an erlang module, 
in order to create an "stub" module. I want to construct an module from a 
interface definition, so I can do something like:

StubModule = adaptor:getStub("anInterfaceId");
Obj = anInterfaceId:createInstance();
StubModule:method1(Obj);
StubModule:method2(Obj, 1, 2);

If there is no reflection the aproximation can be:

Obj = adaptor:createInstance("anInterfaceId");
adaptor:callMethod(Obj, method1, []);
adaptor:callMethod(Obj, method2, [1,2]);

-- 
Greets



More information about the erlang-questions mailing list