Jeff Pang wrote:
>
> Chas Owens wrote:
>>
by convention any function, variable, or hash key that begins with an
underscore, '_', is considered to be private.
>
> Seems not useful.
>
> $ cat t.pl
> {
>     package A;
>     use strict;
>
>     sub _foo {
>         print "hello,world\n";
>     }
> }
>
> {
>     package B;
>     use strict;
>
>     A::_foo();
>     print $A::{_foo},"\n"; # _foo is in A's symbol table
> }
>
> $ perl t.pl
> hello,world
> *A::_foo

What are you trying to achieve Jeff? Are you concerned that someone may write
malicious code that calls package functions that are meant to be private? Or
are you more interested in avoiding coding mistakes caused by calling the
wrong function?

Since Perl is not a compiled language (in the sense that released versions of
the code are source files) there is little point in trying to make code
impossible to call from the wrong context; and the underscore convention that
Chas describes, together with never using package names in object-oriented
identifiers, goes a long way to make mistakes unlikely.

Or was there some other point to your question?

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to