Wednesday, December 16, 2009

KISS

I'm sick of wracking my brain over Newspeak's confounding context/inheritance hierarchy*. It's just too nasty to implement, with so many ifs and buts. So fugger it, I'm going back to Self.

Instead of having complex semantics about how to look up receivers, I'm just going to use multiple inheritance. Setters only effect the object that they are executed within ('this') while Getters go up and down the entire hierarchy.

This may sound slow, but once you've compacted the thing with PICs and so on, it really doesn't matter. I guess you could say that about the Newspeak approach as well, but this is a very simple algorithm and so should be quick to implement.

So where does 'nesting' go? Well, it's essentially a 'super' class, isn't it? In fact, apart from the convoluted semantics for receiver look up, that's all context is in Newspeak as well.

What do we lose? Well, it all ends up much less well defined, which is the power and the pain of Self, and maybe there's a security problem, but I believe most of that will be overcome by making sure that you are Dependency Injected. (Self essentially made everything accessible by containing a slot in Object to the package hierarchy)

So now we start thinking solely in instantiated objects... not pretending that some things are classes and some are contexts. It's all just objects.

Newspeak may prove better, but for my proof of concept I need something that I understand, so this will be it (Sorry Gilad that my brain is just too small)

*eg, I can't get a super receiver to then call an overriding method on the original object - but I'm sure it's just me.

No comments:

Post a Comment