(CC'd to [EMAIL PROTECTED] as it's of general interest)
On Tue, Nov 27, 2001 at 12:45:31AM +0100, Tels wrote:
> Devels::Advocate: Why is ExtUtils::MM_Unix testing for $^O =~
> /something_different_from_unix/ and than using these things, e.g. it is
> doing VMS, etc specific stuff when it's not expected to work on
> VMS, etc?
You are not confused, MakeMaker is.
Because of the way it's written, it's very difficult to properly
subclass ExtUtils::MM_Unix. The actual formatting of the output is
often done in the same method that has the logic to marshal the data.
This means you have to duplicate lots of otherwise perfectly
compatible logic in subclasses.
To put it another way, think of what it would be like to take this
method and try to subclass it for something that's not an HTML page.
sub current_price {
my($self) = shift;
...do lots of calculations to figure out the $current_price...
return "The price of $self->{name} is <B>$current_price</B>.";
}
That's that MM_Unix is like. It has all these big calculations and
then it spits them out in formats specific to Unix, all in one method.
You'd obviously rather have:
sub current_price {
my($self) = shift;
...do lots of calculations to figure out the $current_price...
return $current_price;
}
sub show_price {
my($self) = shift;
my $price = $self->current_price;
return "The price of $self->{name} is <B>$current_price</B>.";
}
and then it's easy to write your own show_price().
package Thingy::PlainText;
@ISA = qw(Thingy);
sub show_price {
my($self) = shift;
my $price = $self->current_price;
return "The price of $self->{name} is $current_price.";
}
It's a big job to try and seperate out the functionality from the form
inside MM_Unix, so somebody decided it would be easier to do this:
sub current_price {
my($self) = shift;
...do lots of calculations to figure out the $current_price...
if( $Is_HTML ) {
return "The price of $self->{name} is <B>$current_price</B>.";
}
elsif( $Is_XML ) {
return "...ummm, I don't actually know XML...";
}
elsif( $Is_Text ) {
return "The price of $self->{name} is $current_price.";
}
else {
return $current_price;
}
}
which just makes everything Really Confusing.
Its on my TODO list to Fix This The Right Way. I was too afraid to
start ripping into it without tests, though. So I'll start as soon as
those are in place.
> PS: Yes, I know the test for MM_Unix is still missing. Run out of time and
> decided not to rewrite it, but to forward tomorrow my copy from the other
> machince. Sometimes I regret not having access to all my data at all times..
Do what I do, carry an eight pound laptop everywhere. :)
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
I knew right away that my pants and your inner child could be best friends.