Friedrich Weber a écrit :
Hi,

I've thought about writing a highly object-oriented language (you know, everything is an object ...) for Neko (maybe like Python). But I stumbled upon the problem that the elementar data types in Neko (integers, float, strings ..) are not real objects (because of performance reasons maybe?), so I can't set slots on them. I can think of two ways of handling that in a object-oriented language: Either I use the Neko data types and the my language -> neko compiler translates method calls on strings to calls to Neko built-in functions with the string as first argument (that's a bit complicated ;-)) - or I create wrapper types, but then I'd get the problem that I can't easily use Neko extensions in the language itself (because then Neko <-> Mylanguage data type conversions would be necessary). Maybe I have overlooked another way of handling that? What would you suggest?

Use basic neko types, and when you have some method calls that matches your API, use a wrapper function.

Exemple, in your Language-X :

  45.multiplyBy(12)

Get Compiled to Neko as :

   wrap(45).multiplyBy(12)

Then "wrap" can do the following :

   wrap = function(v) {
        switch( $typeof(v) ) {
        $tint =>
                var o = $new(IntWrapper);
                o.value = v;
                return o;
        default =>
                return v;
        };
   }

If you have a lot of API methods for your basic types it will add a lot of "wrap", but it's not that much a big issue.

Nicolas

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

Reply via email to