If Perl had better support for anonymous classes a simple solution would be to just create a specialization of the Divisor class (i.e. a subclass).
There would be no need to modify or redefine anything in the Divisor class.# Pseudo code! my $two = new subclass of Divisor { sub divides { $_[1] =~ /[02468]\z/ } };
lodin
In reply to Re: Motivation for replacing object methods at runtime
by lodin
in thread Motivation for replacing object methods at runtime
by Narveson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |