On Fri, Jul 08, 2005 at 08:28:34PM +0200, Robin Redeker wrote:
: On Fri, Jul 08, 2005 at 10:07:24AM -0400, Stevan Little wrote:
: > I have never understood what is wrong with this:
: > 
: > method foo ($self: $bar) {
: >     $self.baz()
: > }
: 
: Thats a fine option to have.
: But therecomes another question to my mind:
: what do i get with writing 'method' instead of
: 'sub'? is it just for seperating subroutines and methods optically
: or is there a deeper reason?

Several deeper reasons.  Though I quibble at characterizing the optical
reason as un-deeper when it might in fact be the deepest reason of all,
or at least closely related to very deep psychological reasons.

Off the top of my head:

    Subs are never inherited.
    Subs are not candidates for indirect object method calls.
    Perl will only call "sub new" when called as a subroutine.
    Subs create list operators, while methods don't.
    Method calls are allowed to be argumentless.
    Methods have access to instance variables.
    Mutating/nonmutating methods can be generated from each other.
    Explicit method declaration allows implicit invocant declaration.
    Distinguishing multi method from multi sub allows different strategies.

: > Why does it have to be some sugared syntax when you can just simple  
: > name it in the parameter list?
: 
: Yes, but there seem to be quite some people who want
: a 'cool' syntax for it. (ie. ./method ()).

I wasn't thinking 'cool', I was thinking 'visually distinctive and
mnemonic'.  I actually think o. is cooler.

: No syntax at all, like in C++ just method() would
: be the shortest. But larry says no, and everyone seems to
: agree.

Just to quibble again, I didn't just say 'no'.  I also said,

    use self "";

And no, everyone doesn't seem to agree.  :-)

Larry

Reply via email to