Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Re: package Foo; isa Bar; why not?

by liz (Monsignor)
on Dec 19, 2003 at 09:37 UTC ( #315771=note: print w/replies, xml ) Need Help??

in reply to Re: package Foo; isa Bar; why not?
in thread package Foo; isa Bar; why not?

isa Foo,Bar; # drops Bar and also spits out warning...
             # works same if you quote Bar, dies if Foo
             # is quoted or we're under strict
That's because it is using indirect object syntax.

Note that you can say:

isa Bar qw(Baz Bas Boo);
which is not so nice as there is no way to explain why "Bar" should be specified differently from "Baz", "Bas" and "Boo". Maybe a more consistent way of specifying multiple inheritance would be:
isa Bar, isa Baz, isa Bas, isa Boo;

main->isa(qw(Foo Bar)); # makes sense... pushes itself onto
                        # @ISA, though
This can be easily fixed in
-push @{caller().'::ISA'}, @_; +push @{caller().'::ISA'}, map {m#^main$# ? () : $_} @_;

... doesn't seem to be as clean of a solution as it could be.

I agree. I think I'll go back to just setting @ISA myself, and making sure they're run at compile time when I put several packages into one file.


Replies are listed 'Best First'.
Re: Re: Re: package Foo; isa Bar; why not?
by Anonymous Monk on Dec 20, 2003 at 10:37 UTC

    This isn't meant as a criticism, however, why use map in place of grep?

    my $caller = caller(); push @{"$caller\::ISA"}, grep $_ ne $caller, @_;

    I do use map with the empty return quite often when a list/array requires filtering and transformation because it tends to make me feel warm and fuzzy inside. Multiple maps and greps can become confusing. However, if all you're doing is filtering then grep to be clearer (and I believe faster, too).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://315771]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2016-10-22 06:58 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (292 votes). Check out past polls.