logo       

"inheritance" order in Perl proxies: msg#00117

programming.swig

Subject: "inheritance" order in Perl proxies

The Perl proxy classes pseudo-inherit from the module they're in, e.g.:

package example::Circle;
@ISA = qw( example example::Shape );

Because the module comes first, a global function takes precedence over a
method defined in a superclass. If there's a global function Foo, and
also a method Shape::Foo, a user who writes

$cir = new example::Circle(3.7);
$cir->Foo();

will probably expect to get Shape::Foo, but will get the global Foo
instead. I can remedy this by switching the order of the "base classes":

package example::Circle;
@ISA = qw( example::Shape example );

Is there a reason not do it this way?

Josh

--
Joshua L. Cherry, Ph.D.
NCBI/NLM/NIH (Contractor)
jcherry@xxxxxxxxxxxxxxxx

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise