Re: private method
- From: "nobull67@xxxxxxxxx" <nobull67@xxxxxxxxx>
- Date: 4 Mar 2007 03:42:09 -0800
On Mar 4, 7:35 am, p...@xxxxxxxxxxxxx (Jeff Pang) wrote upside-down:
[ please don't write upside-down, it's rude ]
by convention any function, variable, or hash key that begins with an
underscore, '_', >is considered to be private.
Seems not useful.
Please define "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
}
The code above does not follow the convention.
I don't see how you can comment on the usefulness of a convention when
you choose not to follow it.
I think you maybe unclear about what you are trying to achieve. The
Perl5 language does not have the concept of private members, but even
if it did somebody who positively wished to bypass the privacy (as you
do above) could so so simply by editing the source to remove the
private specifier.
Yes, private members can be useful - and will be in Perl6 but don't
underestimate the value of unenforced conventions.
.
- References:
- Re: private method
- From: Jeff Pang
- Re: private method
- Prev by Date: Re: private method
- Next by Date: Re: perl char
- Previous by thread: Re: private method
- Next by thread: Re: private method
- Index(es):
Relevant Pages
|