in reply to Avoiding the Use of @ISA = qw(Foo::Bar);

Eh, if I define a class, I sure don't want someone else to define what I am inheriting. If someone has set @INC I surely don't want to be beaten by that - so I set @INC.

You know, if you start giving out advice of the form "don't use this extremely common idiom, because it might bite you", it sure helps your case by given examples or carefully explaining how it can bite you.

Abigail

  • Comment on Re: Avoiding the Use of @ISA = qw(Foo::Bar);

Replies are listed 'Best First'.
Re: Re: Avoiding the Use of @ISA = qw(Foo::Bar);
by Juerd (Abbot) on Jul 15, 2003 at 06:58 UTC

    Eh, if I define a class, I sure don't want someone else to define what I am inheriting.

    It's nice to be able to do so, though. Some classes are a pain to inherit from and adding your own class to its @INC sometimes saves a lot of time. And IMHO, it's less ugly than defining subs in the other package (and the @ISA solution adds nice ->isa() magic, which can come in handy).

    Manipulating someone else's @ISA makes fun things like http://use.perl.org/~Matts/journal/12896 possible :)

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }