Front page | perl.perl5.porters |
Postings from November 2019
Re: Query Parameters
From:
hv
Date:
November 29, 2019 16:58
Subject:
Re: Query Parameters
Message ID:
201911291651.xATGpFP26777@crypt.org
Dave Mitchell <davem@iabyn.com> wrote:
:=head2 Array query parameter
[...]
:Unlike the other query types, this one always examines the raw argument
:list, (i.e. before being sorted for named parameters). Because of this,
:an array query parameter is forbidden from appearing anywhere to the right
:of any named parameter.
Is the transition point only the actual declaration of a named parameter?
It would also be plausible to say that in sub foo(?$have_name, :$name)
the boolean query already introduces the start of processing for named
parameters, and therefore that it should be not permitted to write
sub foo(?$have_name, ?@all, :$name).
:=head2 Hash query parameter
:
:This is most useful in the presence of named parameters. [...]
:
:A hash query parameter can appear anywhere in the signature, including in
:amongst positional parameters, but in that case it is an error unless it
:is an even number of positional parameters before any first named
:parameter:
:
: sub foo($p1, ?%query, $p2, $p3, :$n1, :$n2) { ... } # ok
: sub foo($p1, $p2, ?%query, $p3, :$n1, :$n2) { ... } # compile-time err
Maybe most useful, but not only useful in the presence of named parameters.
As such, it needs to allow for optional positionals. I think for this case
it should be defined explicitly _not_ to check parity, and silently include
a trailing undef if needed.
Hugo