You are right, I forgot about $exports. But I would like to know how nekovm knows that foo is member of proto and not a casual function?
Regards, 2013/3/23 Kacper Gutowski <[email protected]> > On 2013-03-23 12:15:49, Konstantin Tcholokachvili wrote: > > ------------------------------------------------------------------------- > > var proto = $new(null); > > proto.foo = function() { $print(this.msg) } > > ------------------------------------------------------------------------- > > You just create some local variable here and don't export anything. > As documented on http://nekovm.org/doc/vm, loadmodule returns module's > $export variable. So to make it work, simply change your proto.neko to: > > ------------------------------------------------------------------------- > $exports.foo = function() { $print(this.msg) } > ------------------------------------------------------------------------- > > With this change, your lod.neko > > ------------------------------------------------------------------------- > > var proto = $loader.loadmodule("proto",$loader); > > > > var o = $new(null); > > o.msg = "hello"; > > $objsetproto(o,proto); > > o.foo(); // print "hello" > > ------------------------------------------------------------------------- > > Will print "hello" as you expect. > > > K. > > -- > Neko : One VM to run them all > (http://nekovm.org) >
-- Neko : One VM to run them all (http://nekovm.org)
