develooper Front page | perl.perl5.porters | Postings from October 2014

[perl #123069] signature/attribute syntax is awful

Thread Next
From:
Father Chrysostomos via RT
Date:
October 27, 2014 22:56
Subject:
[perl #123069] signature/attribute syntax is awful
Message ID:
rt-4.0.18-8056-1414450589-716.123069-15-0@perl.org
On Mon Oct 27 15:29:25 2014, mauke- wrote:
> The syntax 'sub foo :attributes ($signature) { ... }' is awful. It
> should be 'sub foo($signature) :attributes { ... }'. (This might be a
> candidate for bug #121481.)
> 
> Why? Because syntactically the signature replaces what used to be the
> prototype, and that comes before attributes.

Signatures are fundamentally different from prototypes because they affect solely the body of the subroutine, while prototypes affect callers.  That’s why the attributes go next to the body.

Currently a predeclaration would be the same as the sub declaration itself, except that the latter has more stuff on the end:

sub foo :lvalue;
sub foo :lvalue ($foo) {...}

(Predeclarations are not allowed to have signatures, because they are part of the body.)

So the way it works makes sense to me.

But, ultimately, I don’t care which way it goes.  (Maybe even allow it both ways.)

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: new
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