On Tue, Sep 11, 2018 at 03:47:46AM -0700, ToddAndMargo wrote:
: In Perl, what is the proper terminology?

We're not picky, since Perl has never made a hard and fast distinction
between routines that return values and routines that don't.  You can call
them all functions or routines or procedures interchangeably depending
on whether you're thinking about their return values or their side effects.
Or just call 'em all "subs", that works too.

We do tend to distinguish the term "method", but even those are the
same thing underneath once they're called.  Methods are just routines
that were discovered via method dispatch on the first argument rather
than the usual function calling method.  And there's a little syntactic
sugar to let methods treat their first argument specially.  But you can
take a routine and poke it into a class to turn it into a method, and
going the other way, you can pull a method out of a class and call it
like a function.

So basically, if it's meant to be called with .foo notation, call it a
"method", and if it's meant to be called with foo() notation, call it
whatever you like.  But not "method". :)


Reply via email to