Dan Sugalski wrote:
>
> Basically my preference, if we're going with a per-object .ISA with no
> class ISA fallback, is for each object to be independent and not affect any
> other object when its properties are messed with.

I'm straining to understand the subtle distinction btwn  per-object ISA and
Creating A Class That Holds Only One Object And Blessing This Object Into
It

I think it has to do with what the object claims to be when queried.

The desired semantics could be obtained easily enough by relaxing the
isa() function's matching rules, and regularizing the names of the
extended classes.

        $simplefoo = bless {}, 'foo';

        $extendedfoo = {};
        bless $extendedfoo, "foo:::$extendedfoo"; # yes, that's 3 colons

and rewrite isa() to return true if asked

        $extendedfoo->isa('foo')?


Or maybe this magically occurs whenever you use a method of an instance
as an l-value?


        *{$simplefoo.bark} = sub {print "Shh.  I have been hushed!\n"};

(l-value syntax open for major rewriting)
The idea would be, by assigning to an instance's method, instead of
altering the
method for the whole class, you would copy the instance's vtable into a new
vtable, override the method entry in question.  You could make another
equally skewed foo with the

        bless (reference, blessed-reference)

syntax of bless, even if ref($skewedfoo) still returns 'foo' instead of
something
like 'foo:::0x80f5934'


-- 
                                           David Nicol 816.235.1187
                   ftp://ftp.microsoft.com/developr/interix/gpl.txt

Reply via email to