Sunday, December 6, 2009

when all you have is semantics, is it a surprise that all your problems are with... semantics?


Trying to get the behaviour of message and slot lookup/access/modification correct.

Starting with a 'simple' example of inheritance, I use the above relationships (note: no nested classes yet)

So, Func0 can get at obj1, func0Slot, func0Message as well as obj1.obj1Message and obj1.obj0Message.

Obj1 constructor can get at func0Slot, func0Message, obj1Slot, obj1Message as well as obj0Message. Obj1 can update the value in func0Slot.

Obj0 can get at obj0Slot and obj0Message. Or can it?

Most of my tests have worked, with the relationship between obj1 and func0 being quiet well understood and working well. The problem comes in when I get to inheritance from obj0.

While I can find the appropriate message, the behaviour for updating the slot is broken; reading the slot should (initially) return the value in the original obj0 object - but there is no code to search for slots up the hierarchy... This could be fixed by having the message execute within the context of the original object BUT if the message updated the slot - then the original object would effected rather than the inheriting object. Boo.

So we end up with two context setting schemes. When looking up the context hierarchy, we update the slot where we find it. When looking up the inheritance hierarchy, we update the slot at the bottom of the tree!

But now the slots in parent objects are available (if you dig around) in child objects. Not ideal. And how do I determine which scheme to use - does the code have to specify?!!

So I'm a bit miffed.

No comments:

Post a Comment