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

[perl #123069] signature/attribute syntax is awful

Thread Next
From:
Father Chrysostomos via RT
Date:
January 20, 2015 05:28
Subject:
[perl #123069] signature/attribute syntax is awful
Message ID:
rt-4.0.18-24391-1421731718-1864.123069-15-0@perl.org
On Tue Dec 09 12:21:19 2014, abigail@abigail.be wrote:
> On Tue, Dec 09, 2014 at 08:23:20AM -0500, Peter Martini wrote:
> >
> > +1 to moving signatures before attributes (and -1 to allowing it both
> > ways).  I'll also note that having the signature after attributes leads to
> > an unfortunate and unnecessary case of significant whitespace:
> > 
> > sub foo : attributes ($signature) {}  # signature of '$signature', and an
> > attribute of 'attributes'
> > sub foo : attributes($signature) {}   # no signature, and an attribute of
> > 'attributes'
> > 
> > There's no such ambiguity if the signature is before the attributes
> 
> 
> I had no opinion until you pointed out the significant whitespace
> thingy. That would be horrible.

Attributes are subject to that, regardless of the position of the signature.

$ ./perl -Ilib -e 'sub foo : bar ()'
syntax error at -e line 1, near ": bar ("
Execution of -e aborted due to compilation errors.
$ ./perl -Ilib -e 'sub foo : bar()'
Invalid CODE attribute: bar() at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

So the whitespace argument is irrelevant as far as signatures are concerned.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=123069

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