On 3 Apr 2007, at 08:16, Eric Wilhelm wrote:
# from Yuval Kogman
# on Monday 02 April 2007 03:57 pm:
Then just proxy everything:
For the proper distinction between a setter and a method that
accepts arguments (and should still be shadowed) I guess you need
some meta programming, but the value is dubious IMHO.
[snip]
Just start with a root class and inheritable class accessors. The
variant() method then returns a new class, which only exists in memory
and only contains @ISA, getters, and setters.
my $w10 = FormClass->variant(width => 10);
# that's a "FormClass::+0", which isa('FormClass')
my $blue_w10 = $w10->variant(color => 'blue');
# that's a 'FormClass::+1", which isa('FromClass::+0')
I'm sure that'd work.
I hacked up some code last night that has variant() return a proxy
object that uses AUTOLOAD to route method calls to the real object
per Yuval's example. That seems to work at least well enough to
experiment with.
Having slept on it I think the name for what I'm trying to do might
reasonably be 'object currying'.
--
Andy Armstrong, hexten.net