Le 14/03/2011 23:39, Konstantin Tcholokachvili a écrit :
Hello,

I'm making making a tool which will be able to convert python to neko.
I'm now able to convert for example fibonacci or factorial functions
written in python to neko.
I realised that the code generation must be improved, so I decided to
write python objects in neko (int, float...) and let it behave even
internally as in python like objects.

My question is: How can I define an object which would be instantiated
later in neko?
I saw things like:
o = new(null);
o.value = 5;
o.add = function (n) { o.value = o.value + n }

But how can it be instantiated on the fly?

I'm not sure what you mean exactly by "on the fly".

You can have an existing class prototype which contains all the methods, then simply do the following :

var o = $new(null);
$objsetproto(o,number_proto);
o.value = 5;
return o;

Hope that helps,
Nicolas

--
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to