Am Mittwoch, den 11.03.2009, 17:43 +0100 schrieb Friedrich Weber:
> 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?
> Would be nice if anybody had an idea for that :-)
> 
> Regards,
> 
> Friedrich
> 

Hello,

I'm currently writing a Python implementation for Neko (or at least
trying to). In CPython, instances of builtin types (e.g. int, list, str)
also don't have instance attributes, like Neko values; they do have a
Python class object, though. So, I just disguise Neko values as Python
objects: When I want to know the Python class of an object, I call a
function (which I called ``get_type``) that returns the Python class of
any Neko value: For Neko objects, it looks for a special attribute that
points to the class, but for e.g. a Neko int, it returns the Python int
class. Because of that, from the Python standpoint, any Neko value looks
like an ordinary Python object. Of course, that means I can't use Neko's
attribute access to for Python's attribute access but have to implement
it with a function(``getattr``). That's no problem though, because that
is be required anyway to get Python's dynamic attribute access.
Ok, I'm not sure what I've written is actually understandable, but it's
much more difficult to describe than it is in practice. I hope it's of
use anyway ;)

Regards,

Felix Krull


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

Reply via email to