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

__FILE__ prototype

Thread Next
From:
Zefram
Date:
July 19, 2011 13:49
Subject:
__FILE__ prototype
Message ID:
20110719204917.GQ16369@lake.fysh.org
Just spotted this in perldelta:

    The C<prototype> function now returns a prototype (the empty string) for
    the C<__FILE__>, C<__LINE__> and C<__PACKAGE__> directives, instead of
    dying, as they are indistinguishable syntactically from nullary functions
    like C<time>.

O RLY?

    $ perl -lwe 'print time()'
    1311108151
    $ perl -lwe 'print __FILE__()'
    syntax error at -e line 1, near "__FILE__("
    Execution of -e aborted due to compilation errors.

I'm all for treating them as nullary functions, but that's not currently
what they look like.  I think we can readily resolve this by allowing
empty parens after __FILE__ et al; as shown here, it's currently a syntax
error, so it won't break anything.  (But tread carefully when editing
this stuff.  It is subtle and quick to anger.)

-zefram

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