Hi Michael,
I think I found a flaw in the _object>>_delegated message: it doesn't
know the size of the new type
To fix this, I'd suggest adding a size parameter to
_object>>_delegated.
Problem is, you wouldn't know what to pass as the size argument until
_sizeof is installed in the new type's vtable, and some types
calculate the _sizeof value rather than returning a fixed size.
Catch 22.
The correct fix is probably along the lines of creating the new
prototypical object, installing _sizeof (and _debugName) in its
vtable, then replacing it with its answer to _clone. You can do
(almost) The Right Thing explicitly already:
Prototype : ParentType ( foo bar )
[ Prototype := Prototype new ]
The two things that are missing are:
1. the compiler being clever enough to install a user-defined _sizeof
method (defined in the same translation unit) in the code implicitly
generated for the first (declaration) line; and
2. the compiler generating the second line implicitly during per-file
initialisation.
Another approach, equivalent to the above but closer to your idea,
would be to pass the _sizeof and _debugName method addresses to the
_object._delegated method and have this all taken care of outside the
compiler along the lines of:
_object _delegated_: _size _: _name
[
| temp |
temp := self _vtable _delegated.
temp methodAt: #_sizeof put: _size; methodAt: #_debugName put: _name.
^temp _alloc: { _size() }.
]
Although this requires all the intrinsic types (_selector, _assoc,
_closure, _vector, _vtable) to be defined in some special way
(avoiding _object._delegated_:_: until after they are all defined and
working) which just moves complexity around (into the libid init()
thing).
However, I think I'll almost certainly do it exactly this way in the
combined object/function language of COLA. (Ted Kaehler has been
unhappy about the undersized prototypes for quite a while.)
Cheers,
Ian
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc