in reply to Re: Re: Re: Re: Tie-ing hashes clobbers data
in thread Tie-ing hashes clobbers data

Method, procedure, function. It's all the same thing. The thing that differes is how you call them. I'd say that
sub Foo::new { bless {}, $_[0]; }
is still a method even if you call it with Foo::new($class).

I can say black is white and white is black all day, but I'm still going to get run over at the next zebra crossing because it's not true. Method calls are invoked using $instance->method_name(). That form searches the @ISA tree. Foo::new() is calling a fully specified subroutine. No amount of wishful thinking will ever make that into a method call. Perl is rather flexible in that it will allow you to call most subroutines either way.

And strictly speaking (in a computer sciencey manner), there is a specific difference between a procedure and a function. Compare and contrast foldoc's definitions for function and procedure

Replies are listed 'Best First'.
Re: Um, no.
by Anonymous Monk on Apr 09, 2002 at 22:38 UTC
    I can say black is white and white is black all day

    Or you can ask the author whether it's black or white -- that'll save you from getting run over.

    Method calls are invoked using $instance->method_name().

    Agreed.

    Foo::new() is calling a fully specified subroutine.

    Agreed.

    No amount of wishful thinking will ever make that into a method call.

    When did I claim that? My point was that it's the author that decides whether a subroutine should be a method or not. When I say method I speak of a subroutine that deals with classes/objects and/or is intended to be inherited/overriden, roughly. I believe that's the common interpretation.

    Perl is rather flexible in that it will allow you to call most subroutines either way.

    Exactly. The way we choose to call our subroutine doesn't change what the subroutine is. But if we want to call a private method, we can just as well call it directly -- and we should call it directly. See this node.

    And strictly speaking (in a computer sciencey manner), there is a specific difference between a procedure and a function

    I'm familiar with that from Pascal... But Perl makes no difference. In Perl there's no technical difference between methods, functions, and procedures; they're all subroutines. We are discussing Perl's object model, are we not?

      Your phrasing made it seem as if you were claiming it was a method call. Upon rereading a couple more times, I see what you were implying.

      And I was going to respond further, but I'm getting the distinct impression that IHBT. *plonk*