On Thu, Oct 9, 2008 at 6:04 AM, Peter Scott <[EMAIL PROTECTED]> wrote:
> On Wed, 08 Oct 2008 04:59:19 -0700, John W. Krahn wrote:
>> oldyork90 wrote:
>>> I am using a module having documentation saying document() is a
>>> method.  However, I see it used as
>>>
>>> $o->document;
>>>
>>> Can you reference a method in this way?  (I takes no args).  I always
>>> thought
>>>
>>> $o->document() and $o->document meant different things, function
>>> verses attribute.
>>
>> perldoc perlsub
>>
>>      To call subroutines:
>>
>>          NAME(LIST);    # & is optional with parentheses.
>>          NAME LIST;     # Parentheses optional if predeclared/imported.
>>          &NAME(LIST);   # Circumvent prototypes.
>>          &NAME;         # Makes current @_ visible to called subroutine.
>
> That isn't particularly relevant to the effect of leaving parentheses off
> method calls.  You don't use & with methods (unless you're being
> perverse).  Methods ignore prototypes.  And @_ is not passed through when
> parens are left out on method calls.
>
> In fact, I can't find anything in perldoc about parens being optional on
> method calls.  All the examples I find leave in even empty ones.  Of
> course you can leave them out.  Parenthesis-less calls are documented in
> the Camel ("Method Invocation") but not given any special attention.
> I guess that got added in the third edition when there started to be
> divergence between the Camel and perldoc.
>

Actually, it's quite relevant. The important thing to remember is that
Perl has no inherent concept of objects or methods. Objects are just
subroutines that call bless() on themselves. The rules for passing
arguments to all subroutines apply to objects. The perlobj perldoc
also information on the "indirect object syntax" and how it applies,
in often quirky ways, specifically to method invocations.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to