develooper Front page | perl.perl5.porters | Postings from November 2017

Re: square signatures

Thread Previous | Thread Next
From:
Sawyer X
Date:
November 20, 2017 11:58
Subject:
Re: square signatures
Message ID:
da791552-2aff-1a88-922a-a4b01ac45948@gmail.com


On 11/13/2017 09:07 PM, Zefram wrote:
> There is a change we could make to signature syntax, within the scope of
> the present experimental feature, which would have some value and which
> I think we should consider making.  The change I propose is firstly that
> signatures should be delimited by square brackets instead of parentheses,
> and secondly that enabling signature syntax should not disable the short
> prototype syntax.  Under this arrangement we would see things like:
>
>     use feature "signatures";
>     sub add [$x, $y] { $x + $y }            # signature
>     sub my_rand (;$) { rand($_[0] || 5) }   # prototype
>     sub mul ($$) [$x, $y] { $x * $y }       # prototype and signature
>
> [...]

I haven't responded to this thread yet because I'm still processing my
inbox. I imagine it would be valuable for me to weigh in, so:

I appreciate the separation this gives between signatures and protoypes,
but I think ":prototype" provides a clearer separation still, and I
appreciate expressiveness.

Additionally, regardless of breaking any existing code (which we could
surely reduce), it also breaks what we expect signatures to look like.

Lastly, while prototypes are useful, I believe signatures are more
valuable for users, especially for beginners (or really, anyone who
wants to reduce code and work and add expressiveness in parameters),
which means we should optimize for that, rather than second-citizen it
to a lesser syntax.

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