>>>>> "JP" == Jeff Pang <jeffrp...@gmail.com> writes:

  JP> 2011/4/28 Uri Guttman <u...@stemsystems.com>:
  >> 
  >> the _ prefix is the only common way to mark a private OR protected
  >> method as perl doesn't directly provide any support for it. moose and
  >> other OO systems may support this.


  JP> I may think Perl OO (not moose) doesn't have private or protected
  JP> methods as other languages like Java/Ruby.
  JP> _method can be accessed from anywhere.

  JP> package A;

  JP> sub new { bless {},shift }
  JP> sub _test { print 1 }

  JP> package B;

  JP> my $obj = A->new;
  JP> $obj->_test;


  JP> That works.

i said it was a convention and perl doesn't support it directly. it
means coders mark internal (a better name than protected or private)
methods with a _ prefix. as i also said the pod coverage module (used in
tests to make sure you document all your methods and subs) will skip
internal methods. this is used by most perl coders all over so it is
accepted. calling an internal method from outside the class is a bad
thing.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to