On Aug 1, 2010, at 6:59 PM, Jeff Fearn via RT wrote:
Show quoted text> <URL:
http://rt.cpan.org/Ticket/Display.html?id=58880 >
>
> Are you talking about removing the parentheses from the ABORT OK PRUNE
> PRUNE_SOFTLY PRUNE_UP subs?
>
> If so, that was deliberate as it generated perl critic warnings for bad form.
>
> If not, please specify the constants you mean.
I do mean those constants. I suspect the warning was added to perlcritic because some beginners misuse them and put them on all their subroutines (and then wonder why they get syntax errors).
The sole purpose for empty parentheses after a sub name is to make it parse as a 0-ary (nihilary?) function. I.e., ABORT+1 should parse as ABORT()+1, not ABORT(+1). The parentheses also tell perl that it can be inlined.
Deparse is really useful for demonstrating this:
$ perl -MO=Deparse,-p -e 'sub ABORT {7} print ABORT+8'
sub ABORT {
7;
}
print(ABORT(8));
$ perl -MO=Deparse,-p -e 'sub ABORT() {7} print ABORT+8'
sub ABORT () { 7 }
print(15);
-e syntax OK
With the parentheses, it not only makes it parse as a term. It even resolves the constant at compile-time, making the code run faster.
Show quoted text>
> Cheers Jeff.
>
> P.S. Sorry for the lag in replying, I've been recovering from an operation.
>
> On Mon, Jun 28, 2010 at 7:17 AM, Father Chrysostomos via RT
> <bug-HTML-Tree@rt.cpan.org> wrote:
>> Sun Jun 27 17:17:11 2010: Request 58880 was acted upon.
>> Transaction: Ticket created by sprout@cpan.org
>> Queue: HTML-Tree
>> Subject: constants for traverse are no longer parsed as such
>> Broken in: (no value)
>> Severity: (no value)
>> Owner: Nobody
>> Requestors: sprout@cpan.org
>> Status: new
>> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=58880 >
>>
>>
>> I think you have inadvertently removed the () prototypes from the constants used to control the traverse method. This changes the way they are parsed. I doubt this will affect any code, though. Just something to take into account....
>>
>>
>>
>