On Fri, Jul 22, 2005 at 07:35:30AM -0500, Collin Winter wrote:
: > I'm not married to the colon.  Speaking of traits and adverbs, why not use
: > one of those in the "has" declaration instead?  That'd certainly be a lot
: > more explicit than the magic leading underscore (although I'm at a loss as
: > to what the trait would be named...)
: 
: I'd like to see an "is private" trait used for this purpose. This
: could be used in the "has" declaration alongside the existing "is rw"
: and company, possibly in method declarations as well, like so:
: 
: method foo() is private {...}
: 
: I may have missed a previous debate over this in the past, but this
: seems a lot more natural to me than a magical leading underscore.

Well, yes, most people missed that debate, because it was mostly done
on whiteboards in secret meetings of the cabal.  (There is no cabal.)

The problem I have with "is private" is that, while there may very
well be a trait of that name that you can interrogate, I really
want people to think of the private methods as being in a different
namespace so that there's no confusion about the fact that you can
have a private method and a public method of the same name.  And the
reason I want that is because I strongly believe that private methods
must be absolutely invisible to the public interface, and confusing
the namespaces puts you in a situation where adding a private method
can clobber public inheritance of the same name.

Even worse, it clobbers your private interface.  As soon as you say

    method foo() is private {...}

then you can't call $?SELF.foo() and expect to get the public .foo method.
Putting the difference as part of the name forces people to distinguish

    $?SELF.foo()
    $?SELF._foo()

on the call end.  And the _ has the advantage of being *perceived* as
part of the name.  The problem with

    $?SELF.:foo()

is that people see that as a .: operator on the foo method.

Larry

Reply via email to