On Sat, 03 Mar 2007 22:23:04 -0500, Jeff Pang wrote:
> Does Perl's OO have "private method" like Python and other OO languages?
> When we say "sub foo { }" in a package 'bar',Perl will insert the "foo"
> into this package's symbol table,so
"Chas Owens" schreef:
> www.nas.nasa.gov/News/Techreports/2000/PDF/nas-00-008.pdf.
Recently I was playing with something similar, when context-variables
were discussed on perl6.language:
#!/usr/bin/perl5 -l
use strict;
use warnings;
sub context {
sub bad_scope { $_[0] .q/->context, b
On Sun, 2007-03-04 at 14:31 +0100, D. Bolliger wrote:
> Chas referred to a _convention_ - which does not enforce privacy.
> IMO it's useful, otherwise it would not be widely used, and for example,
> Test::Pod::Coverage would require subroutines starting with an underscore to
> be documented. :-)
On 3/4/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
snip
In fact nothing at all.I'm also using Perl's OO well.But when programming
with Python,I sometime would like to declare a subroutine as private.For this
private method,someone can't access it from out of the class.So I th
all.I'm also using Perl's OO well.But when programming with
Python,I sometime would like to declare a subroutine as private.For this
private method,someone can't access it from out of the class.So I think that
Perl doesn't have this feature.:-)
--
To unsubscribe, e-mail: [EMAIL
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";
> }
>
Jeff Pang am Sonntag, 4. März 2007 08:35:
> >by convention any function, variable, or hash key that begins with an
> > underscore, '_', is considered to be private.
>
> Seems not useful.
[ example snipped]
Hello Jeff
Chas referred to a _convention_ - which does not enforce privacy.
IMO it's usef
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
>by convention any function, variable
On 3/3/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
Does Perl's OO have "private method" like Python and other OO languages?
snip
Perl does not have such a construct; however, by convention any
function, variable, or hash key that begins with an underscore, '_',
is c
Does Perl's OO have "private method" like Python and other OO languages?
When we say "sub foo { }" in a package 'bar',Perl will insert the "foo" into
this package's symbol table,so we can access foo() from anywhere out of the
package bar,via t
10 matches
Mail list logo