I haven't actually used Ruby, despite intentions to do so, mainly since
I can whip things up in Perl more easily and so am inclined to do that.
So I'm not that familiar with what ``mixins'' are or how they're used,
other than what I recall from reading some Ruby books and a bit of the
ruby discussion list, but I think I may be able to see how they might
relate to the thinobject scheme.
The thinobject 'enabler' script, tob or thinob, resolves methods by
following ^ links in objects and clases. Directories in a class should
be ignored, since they would (possibly) represent subclasses of the
class but bear no significance to the class itself.
That flies in the face of what I was thinking, which was to somehow
specify, in addition to the ^ link to parent class, another link that
would be followed in the resolution phase. Without knowing enough about
ruby mixins, I suspect that this would be similar.
The 'normal' class hierarchy (tree?) strictly follows the ^ links, and
so a method might be resolved under an object as ^/foo or ^/^/^/foo,
possibly both. Mixins would provide an additional path to resolve a
method, i.e., when no method has been identified, before failing, so
that maybe something like ^/^/^mixin/bar could be found.
The convention implicit in that would be that a mixin class link would
identify the class (and be linked directly to it), but the name would
begin with '^' and include the class name.
I can see that this is doable, and could implement it in thinb/tob.
But wait; there's more... I vaguely recall that Ruby stipulates something
about mixins, possibly that resolution doesn't descend beyond the
immediate mixin class? That seems unlikely, as an arbitrary class must
necessarily depend on its own class tree to provide all of its behaviors.
So I guess I ought to look into how Matz worked this out. It's also
probably a good idea not to go adding features without a clear need,
and so far I haven't had a need to step out of normal class resolution.
Mixins are supposedly (to my limited knowledge) a limited form of
multiple inheritance. Might they be useful?
Ken
--
Ken Irving, fn...@ua..., http://sourceforge.net/projects/thinobject/
Hi=~/lib/thinob/Try/Hi; mkdir -p $Hi; ln -s /usr/local/lib/thinob $Hi/^
hi=$(tob Try/Hi.tob hi); echo -e '#!/bin/sh\nshift\necho Hello $*!' > $hi
chmod +x $hi; mkdir say; ln -s $Hi say/^; tob say.hi world
|