in reply to Re^2: Private method variations
in thread Private method variations
Perl 6 will have a compromise solution to this. The calling style for a private method is very like, but not quite the same as, the calling style for a public method. All private attributes and method names will start with a distinguishing character, which at the moment I would guess is colon, though at one time it was exclamation mark. Anyway,
In this way, you don't have to change your argument passing--it's just a matter of inserting an extra character. The calls are also self-documenting, since you can tell by inspection whether you're looking for something public or private. Likewise, any use of $.foo is obviously public, while any use of $:foo is obviously private.has $.foo; # public attribute has $:bar; # private attribute method foo (){...} # public method method :bar () {...} # private method ... $self.foo() # always calls public method virtually .foo() # unary variant $self.:bar() # always calls private method .:bar() # unary variant ... $self.bar() # calls public bar, not private.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Private method variations
by adrianh (Chancellor) on Mar 01, 2004 at 22:11 UTC | |
by TimToady (Parson) on Mar 02, 2004 at 00:57 UTC | |
by adrianh (Chancellor) on Mar 02, 2004 at 01:40 UTC | |
by TimToady (Parson) on Mar 02, 2004 at 03:47 UTC | |
by adrianh (Chancellor) on Mar 02, 2004 at 11:56 UTC | |
Re: Re: Re^2: Private method variations
by duff (Parson) on Mar 01, 2004 at 20:58 UTC | |
by TimToady (Parson) on Mar 02, 2004 at 00:46 UTC |