| Next | Twelve Talks in One | 15 |
Example: Add a code preprocessing step
Create subclass, add preprocessor method:
sub preprocessor {
my ($self, $pp) = @_;
$self->{PREPROCESSOR} = $pp;
}
Override ->compile() method:
sub compile {
my ($self, $code) = @_;
if (defined $self->{PREPROCESSOR}) {
$code = $self->{PREPROCESSOR}->($code);
}
return $self->SUPER::compile($code);
}
Problems: Representation and interface dependency
Solution: Subclassing interface contracts?
| More Details | ![]() |
Copyright © 2003 M. J. Dominus |