View previous topic :: View next topic |
Author |
Message |
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Sat Nov 08, 2008 1:11 pm Post subject: Haha, class-based OO. |
|
|
After almost a year of proto-based OO, I'm going to take MD2 back to class-based OO.
Within a month of it being released.
Why? Well proto-based OO works great within MiniD. It's simple and flexible. But writing proto-based native objects creates a lot of problems. There are some nasty loopholes that allow you to create all manner of subclasses and instances of native objects that are malformed - missing hidden fields, uninitialized, etc. These problems really didn't exist with the old implementation, but they've really cropped up with the new one, and there's not a lot that can be done to stop them.
Secondly, I've noticed that I've built up this set of functionality that makes it easier to write class-like objects within the proto-based framework. This is kind of funny, but not entirely unexpected. It turns out that class-based OO works great for a lot of things. Most of the time, operations that are performed on instances make no sense when performed on classes and vice versa. Proto-based OO doesn't help a lot here.
The final nail in the coffin, though, is the binding library. The two problems above compound and make the binding library not only hard to write, but easy to break. This is not what I want.
These new classes, however, will not be like MiniD 1's classes. They have a lot of problems, some of which proto-based OO has solved. So these new classes will be sort of a mix of the two approaches. There will be classes and instances, yes. But things like correctly-working supercalls, differential inheritance of fields, dynamic modification, and a singly-rooted inheritance hierarchy are too nice to give up.
Here's what I'm thinking, as far as what members each type will have:
Class
- name
- base (have Object-rooted class hierarchy)
- fields (like objects, have methods and other fields together)
- allocator (to allocate instances - normally just calls newInstance)
- This is so you can allocate extra fields and bytes inside an instance, or do other bookkeeping
- finalizer (not called on it, but given to instances)
Instance
- parent (class)
- fields (only those that differ from class)
- finalizer (inherited from class, called when collected if it has one)
- This might not even be necessary, since the parent has it
- extra fields and bytes (same as objects have now)
That's that. I don't actually expect this to be much of a change in the code, so you'll probably see this done if not today, then in the next couple days. |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Sat Nov 08, 2008 6:09 pm Post subject: |
|
|
It... is... finished. |
|
Back to top |
|
|
h3r3tic
Joined: 30 Mar 2004 Posts: 261 Location: Torun, Poland
|
Posted: Sat Nov 08, 2008 7:28 pm Post subject: |
|
|
s/It\.\.\. is\.\.\. finished\./we are the borg. resistance is futile./
great work! |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Sat Nov 08, 2008 7:47 pm Post subject: |
|
|
u. |
|
Back to top |
|
|
dhasenan
Joined: 03 Feb 2005 Posts: 73 Location: New York
|
Posted: Mon Nov 10, 2008 10:14 am Post subject: |
|
|
Yay! I can actually use this!
Class-based OO is a lot easier to secure than prototype-based, at least insofar as I can plan it. Secure from malevolent users and secure from stupid people like me. |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon Nov 10, 2008 3:05 pm Post subject: |
|
|
Hehe. |
|
Back to top |
|
|
dhasenan
Joined: 03 Feb 2005 Posts: 73 Location: New York
|
Posted: Wed Nov 12, 2008 9:50 am Post subject: |
|
|
And the peasants rejoiced! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|