I have a question and a request.
In http://perlcabal.org/syn/S06.html#Named_subroutines it says:
The general syntax for named subroutines is any of:
my RETTYPE sub NAME ( PARAMS ) TRAITS {...} # lexical only
our RETTYPE sub NAME ( PARAMS ) TRAITS {...} # also package-scoped
sub NAME ( PARAMS ) TRAITS {...} # same as "our"
The return type may also be put inside the parentheses:
sub NAME (PARAMS --> RETTYPE) {...}
In http://perlcabal.org/syn/S06.html#Subroutine_traits there is a distinguishing
between 'of' and 'returns', such that 'of' is part of the external routine
signature and 'returns' is just an internal constraint.
Now first of all I wanted to ask/clarify, are all of the above forms, the
"RETTYPE sub" and "--> RETTYPE", equivalent to the "of" trait, meaning they are
part of the external signature, and that none are like "returns" being internal
to the routine only? That's how I hope it is.
Second, since the "sub NAME (PARAMS --> RETTYPE) {...}" form looks nice
visually, I would like to request a variant of that form, that flips the arrow:
sub NAME (RETTYPE <-- PARAMS) {...}
I ask because I like to declare my result type before my parameters, since the
declaration then reads in the same order as corresponding invocation items, as
well as having the shorter and more important declaration appearing first
(result type vs parameters):
my $result = myfunc( $arg1, $arg2 );
And at the same time it has the visually distinctive arrow syntax which is very
easy to read.
While "RETTYPE sub" and "of RETTYPE" provides the first advantage, it doesn't
provide the second.
Also providing both versions gives symmetry in the way that you have both of the
<== and ==> feed operators so users can order operations visually as per their
preference.
I also don't believe you are already using <-- for anything so it is free.
And I don't believe that there should be any problem incorporating this option
given the other issues like named invocants or longname parameters; you just
keep those with PARAMS as you did before, putting the lot on the right side of
the <--.
Note that this request is only useful to me if the existing --> means 'of' and
not 'returns'.
Thank you in advance for considering this request.
-- Darren Duncan