trifork / erjang

A JVM-based Erlang VM
http://www.erjang.org
Apache License 2.0
726 stars 62 forks source link

Serialization of EFun objects for exported functions isn't implemented #47

Closed eriksoe closed 13 years ago

eriksoe commented 13 years ago

==== Current behaviour: 1> erlang:term_to_binary(fun erlang:'not'/1). \ exception error: {not_implemented,"Encode for erjang.m.erlang.ErlBif$FN_not__1", "erjang.EObject.encode(EObject.java:435)"}

==== Desired behaviour: Function objects for exported functions should be serialized using EOutputStream.write_external_fun(module, function, arity).

eriksoe commented 13 years ago

At present, the EFun objects for exported functions do not contain their module and function name except as encoded in the class name.

Related, EFun subclasses for closures contain much code which could be moved to a common superclass for all similar closures:

I suggest that common superclasses be introduced:

In addition to solving the present issue for exported functions, class sizes (and possibly module loading time?) would be reduced.

eriksoe commented 13 years ago

Note that while erlang:term_to_binary(fun erlang:'not'/1). fails, an equivalent function object can be encoded: erlang:term_to_binary(fun(X)->erlang:'not'(X) end). with success. (This is due to encode() being code generated for all local functions but for none of the exported ones.)

eriksoe commented 13 years ago

Implemented (along with common superclasses for exported functions).