develooper Front page | perl.perl5.porters | Postings from January 2011

Re: Time to update POSIX.pm?

Thread Previous | Thread Next
From:
Tom Christiansen
Date:
January 30, 2011 11:11
Subject:
Re: Time to update POSIX.pm?
Message ID:
29227.1296414671@chthon

> The only exception for non-core-like functions that I find
> sensible is using the empty prototype for constant functions:

>   $ perl -wE 'sub FOO {3}; say FOO+1'
>   3

>   $ perl -wE 'sub FOO () {3}; say FOO+1'
>   4

> Without the prototype the "FOO+1" is parsed as "FOO(+1)"
> instead of "FOO()+1".

Even that is only if you just happen to have a forward 
declaration of the function.  Otherwise it's a filehandle 
literal in the dative slot:

    % perl -wE 'say FOO+1; sub FOO {3}'
    say() on unopened filehandle FOO at -e line 1.

    % perl -wE 'say FOO(+1); sub FOO {3}'
    3

    % perl -wE 'say FOO()+1; sub FOO {3}'
    4

--tom

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About