[tpm] private method call nuances

Uri Guttman uri at stemsystems.com
Mon Jul 20 20:10:10 PDT 2009


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

  MK> Can you explain, or point me somewhere to better understand, how
  MK> inheritance breaks using the '&' method? Also, I was a little
  MK> unclear... if you pass in '$self', does that restore the inheritance?
  MK> I just want to be clear so that I can best explain it in my paper.

& doesn't break inheritance, just calling the method as a sub breaks
it. only $obj->method or CLASS->method are proper OO calls that will use
inheritance. (yes, i skipped indirect method calls for good reason). on
top of the lack of inheritance, &sub calls are nasty in another way. if
you don't pass in args to them, they call the sub with the existing
@_ which can be a nasty surprise as you might have expected the sub to
be called with no args. so you are doing two wrong things by calling a
method with &method( $self ).

the perl docs explain all of this so refer to them as usual.

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