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

[perl #123069] signature/attribute syntax is awful

Thread Next
Father Chrysostomos via RT
October 27, 2014 22:56
[perl #123069] signature/attribute syntax is awful
Message ID:
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

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About