in reply to Re^3: Beyond Inside-Out (details)
in thread Beyond Inside-Out
Yes, a much simpler and more direct solution to some of the problems that "inside-out" objects are being promoted to address1.sub ego { $_[0] ||= {}; my $corona= shift @_; my $pkg= caller(); for my $ego ( $corona->{$pkg} ) { $_= shift @_ if @_; $_ ||= {}; return $_; } }
Yes, that's similar with one important difference: In your implementation, the object proper is its corona (a hash). The way I have it in Alter, the object itself can be whatever it is, the corona is attached via magic, and accessed through the magical ego() function.
That leaves the possiblity for the object proper (the "carrier") to be whatever it needs to be to support a conventional class. That answers the question of mixed inheritance. Like with inside-out, any class can inherit from an Alter-based class, and in reverse, an Alter-based class can inherit (without further ado) from one conventional class. Both work by making the conventioonal object the carrier.
As for method-borrowing, a la
why, yes, the borrowed method would continue to access the alter ego that was established in Bar. That's what I would expect in any case.package Foo; *brrowed_meth = \ &Bar::meth;
As to the more general problem of the various meanings of caller, if I'm not mistaken what I'm using is the package that was in force when the call to ego() was compiled. That is excatly what I want: Mehods compiled in a class access the alter ego specific to that class, and that's the only way.
Anno
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Beyond Inside-Out (class)
by tye (Sage) on May 29, 2007 at 17:46 UTC | |
by Anno (Deacon) on May 29, 2007 at 19:50 UTC | |
by shmem (Chancellor) on May 29, 2007 at 20:26 UTC | |
by tye (Sage) on May 29, 2007 at 21:35 UTC | |
by shmem (Chancellor) on May 30, 2007 at 14:22 UTC | |
by tye (Sage) on May 30, 2007 at 15:43 UTC | |
|