FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Haha, class-based OO.

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Sat Nov 08, 2008 1:11 pm    Post subject: Haha, class-based OO. Reply with quote

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
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Sat Nov 08, 2008 6:09 pm    Post subject: Reply with quote

It... is... finished.
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Sat Nov 08, 2008 7:28 pm    Post subject: Reply with quote

s/It\.\.\. is\.\.\. finished\./we are the borg. resistance is futile./

great work! Laughing
Back to top
View user's profile Send private message MSN Messenger
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Sat Nov 08, 2008 7:47 pm    Post subject: Reply with quote

u.
Back to top
View user's profile Send private message
dhasenan



Joined: 03 Feb 2005
Posts: 73
Location: New York

PostPosted: Mon Nov 10, 2008 10:14 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Mon Nov 10, 2008 3:05 pm    Post subject: Reply with quote

Hehe.
Back to top
View user's profile Send private message
dhasenan



Joined: 03 Feb 2005
Posts: 73
Location: New York

PostPosted: Wed Nov 12, 2008 9:50 am    Post subject: Reply with quote

And the peasants rejoiced!
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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