More on the Implementation of xX
Prototype-Based Programming
I was thinking about how to implement objects in the VM and standard library, and I was completely focused on traditional class-based objects. But then, I remembered how it was like to use objects in JavaScript, and as I continued my research, I came to discover prototype-based programming. This class-less form of object-oriented programing provides pseudo-inheritence by simply making copies of exsisting objects. The object a new object is copied from is considered a prototype. What I like most about this technique is that objects can be effectively developed as-you-go. This will help a great deal when developing the standard library because I won't have to commit to an object hiarchy. Inheritance with prototypes is loose. This would essenstially make xX type-less! WHOO!
Objects
With prototypes, objects usually have something called slots. Slots are basically the members of an object. This includes both data members (variables) and methods (functions). So, I'm thinking about supporting this with xX objects. Or, something like it. An xX object struct would look something like this:
This is similar to how Python objects have the dictionary obj.__dict__ which holds basically everything the object has. I think this will aid to implement message passing.
Message Passing
Like Smalltalk, Objective-C, and some others, I would like to implement message passing to execute object functions. I think this goes great with a class-less (and somewhat type-less) system. This means, the VM knows nothing about primitive data types such as integers, strings (not always primitive), and the like. Actually, it will probably know a little about strings. This keeps the VM small, at the expense of a possible performance penalty. Such data can be off loaded into the standard library assisting with development. For example, the standard library would have a Number prototype that can be used to handle numerical operations. Most likely, such a module will have to be written in C, but it could be loaded into the VM and used to create numbers. The Number prototype will then respond to the add message. Somthing like that. Who knows. I also think message passing will help provide support for co-routines, an alternative to multi-threading.
Prototype-Based Programming
I was thinking about how to implement objects in the VM and standard library, and I was completely focused on traditional class-based objects. But then, I remembered how it was like to use objects in JavaScript, and as I continued my research, I came to discover prototype-based programming. This class-less form of object-oriented programing provides pseudo-inheritence by simply making copies of exsisting objects. The object a new object is copied from is considered a prototype. What I like most about this technique is that objects can be effectively developed as-you-go. This will help a great deal when developing the standard library because I won't have to commit to an object hiarchy. Inheritance with prototypes is loose. This would essenstially make xX type-less! WHOO!
Objects
With prototypes, objects usually have something called slots. Slots are basically the members of an object. This includes both data members (variables) and methods (functions). So, I'm thinking about supporting this with xX objects. Or, something like it. An xX object struct would look something like this:
typedef struct xxObject_t
{
xxDictionary *slots;
} xxObject;
This is similar to how Python objects have the dictionary obj.__dict__ which holds basically everything the object has. I think this will aid to implement message passing.
Message Passing
Like Smalltalk, Objective-C, and some others, I would like to implement message passing to execute object functions. I think this goes great with a class-less (and somewhat type-less) system. This means, the VM knows nothing about primitive data types such as integers, strings (not always primitive), and the like. Actually, it will probably know a little about strings. This keeps the VM small, at the expense of a possible performance penalty. Such data can be off loaded into the standard library assisting with development. For example, the standard library would have a Number prototype that can be used to handle numerical operations. Most likely, such a module will have to be written in C, but it could be loaded into the VM and used to create numbers. The Number prototype will then respond to the add message. Somthing like that. Who knows. I also think message passing will help provide support for co-routines, an alternative to multi-threading.


0 Comments:
Post a Comment
<< Home