[tpm] Stupid question time... Why does @ISA have to be scoped global?

Uri Guttman uri at stemsystems.com
Fri Aug 14 10:02:55 PDT 2009


>>>>> "MK" == Madison Kelly <linux at alteeve.com> writes:

  MK> As I understand it, when you have a package like:
  MK> package Aaa::Bbb;

  MK> use Aaa::Bbb::Foo;

  MK> our @ISA=("Aaa::Bbb::Foo");

  MK> ...

  MK> Package "Aaa::Bbb" will consult it's @ISA to look for packages to look
  MK> for methods in when it doesn't have the requested method itself. As I
  MK> understand it, this would make me think only that package accesses the
  MK> @ISA array. So why then does 'perlmod' say:

  MK> Such a package may also derive some of its methods from another class
  MK> (package) by listing the other package name(s) in its global @ISA
  MK> array (which must be a package global, not a lexical).

packages don't scan @ISA, perl does. and it uses the names in @ISA to
find package namespaces to search for methods. and each package can
provide its own @ISA so they have to be package globals to be found. if
they were lexicals they could (easily) be found by perl. also there are
other modules which do wierd things with the @ISA tree and need to be
able to see them too.

uri

-- 
Uri Guttman  ------  uri at stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


More information about the toronto-pm mailing list