develooper Front page | perl.perl5.porters | Postings from August 2008

the warning about parents in Universal->isa

Thread Next
From:
Nicholas Clark
Date:
August 22, 2008 07:56
Subject:
the warning about parents in Universal->isa
Message ID:
20080822145629.GG75181@plum.flirble.org
If all your packages are present, all is happy:

$ cat ~/test/with.pl
#!perl -w

use strict;

package Pie;

package Cow::Pie;

@Cow::Pie::ISA = 'Pie';

package main;

print Cow::Pie->isa('Pie') ? "Mmm, pie\n" : "Waaah!\n";

__END__
$ ./perl -Ilib ~/test/with.pl 
Mmm, pie

However, if they are not:

$ cat ~/test/without.pl 
#!perl -w

use strict;

# package Pie;

package Cow::Pie;

@Cow::Pie::ISA = 'Pie';

package main;

print Cow::Pie->isa('Pie') ? "Mmm, pie\n" : "Waaah!\n";

__END__
$ ./perl -Ilib ~/test/without.pl
Can't locate package Pie for @Cow::Pie::ISA at /home/nick/test/without.pl line 13.
Can't locate package Pie for the parents of Cow::Pie at /home/nick/test/without.pl line 13.
Waaah!


Then you ISAn't what you think you ISA. Which seems somewhat wrong.
(The first warning is in Perl_gv_fetchmeth() as it looks up the tree for ->isa
That seems legitimate. The second warning is from this code in S_isa_lookup():

	if (!basestash) {
	    /* We have no test coverage for this block, as of 2008/08.  */
	    if (ckWARN(WARN_SYNTAX))
		Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
			    "Can't locate package %"SVf" for the parents of %s",
			    SVfARG(basename_sv), hvname);
	    continue;
	}


The top of that function says:

/*
 * Contributed by Graham Barr  <Graham.Barr@tiuk.ti.com>
 * The main guts of traverse_isa was actually copied from gv_fetchmeth
 */


Is that warning really needed?
Independently of that, is that continue buggy?

To my mind it seems more logical behaviour that you ISA what you say you ISA,
always, rather than the intersection of what you say you are, and what is
loaded. After all, you get a warning (and probably an error) if you try to
do anything based on what you say you ISA if it's not loaded.

Nicholas Clark

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About