Hi
Am 2010-11-02 um 10:24 schrieb eMko:
> There is a convention of naming private methods - instead of naming it just
> "methodName" you can use "myMethodName".
>
> I have seen this convention in some tutorials at squeak wiki but have not
> seen a system class in squeak or pharo which uses this. But I do in my
> programs. A different naming convention of private/protected methods is
> quite common in other programming or scripting languages like Perl, Python,
> PHP ...
Incidentally, if you name your method "pvtMethodName" it is expected that
this message is only sent to self.
So if you have a class
"--"
Object subclass: #Foobar
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'TMP'
"--"
with
Foobar>>pvtTest
Transcript show: 'Foobar'.
and then do
| a |
a := Foobar new.
a pvtTest.
you'll end up with the Compiler telling you
that “Private messages may only be sent to self”.
However, according to Smalltalk conventions, you should
use these “private” methods scarcely. In fact, it is easy to
circumvent this check:
| a |
a := Foobar new.
a perform: #pvtTest a Foobar
works easily, so don't rely on the privateness. However,
whatever one sends to your object is up to her/him and
she/he is responsible for the outcome ;)
HTH
So Long,
-Tobias
_______________________________________________
Pharo-users mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users