Re: private method



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.

.



Relevant Pages

  • Re: Comments on code layout requested
    ... the variables I defined in my constructor (the "private" variables). ... As for public properties, it makes no difference. ... evangelism: XHTML 1.0 Strict ...
    (comp.lang.javascript)
  • Re: Is there a future for Borland in .NET?
    ... accessing private and protected members. ... Strict does away with this. ... disable the cracker class technique. ...
    (borland.public.delphi.non-technical)
  • Re: Elementary Qs on objects
    ... the hint box includes both the Private FaBoolean and the Public ... to the class and its descendants, plus the rest of the unit, plus the ... Delphi 2005 introduces two new visibility specifiers, "strict private" ...
    (alt.comp.lang.borland-delphi)
  • Re: Indexing
    ... I wanted to tell you about this and more in private, but unfortunately, ... something appears to be wrong with your mailbox: ... evangelism: XHTML 1.0 Strict ...
    (comp.lang.javascript)
  • Re: Proper program structure
    ... type Car is limited private; ... define each type in a separate package. ... package body Cars.Gear_Box is ...
    (comp.lang.ada)