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

Re: Named argument syntax (was Re: PSC #049 2022-01-07)

Thread Previous | Thread Next
October 4, 2022 13:41
Re: Named argument syntax (was Re: PSC #049 2022-01-07)
Message ID:
Reviving an old discussion ...

On Mon, Jan 31, 2022 at 9:50 PM Dave Mitchell <> wrote:

> Just to be clear here. I fully expect that function calls will always
> consist of the caller passing a list to the function, and that the
> proposed named parameter syntax  is just a way of easily processing
> adjacent pairs of values in that list. So in:
>     sub foo(:$x, :$y) { ... }
> The caller is expected to pass 4 arguments. How the caller does this is up
> to the caller. They could do
>     foo('x', 1, 'y', '2');

Since arrays and hashes are flattened into a list, it seems that someone
might do sub foo(:@bar) {...} and get surprising results. Either it doesn't
do what they expect, or it's a syntax error. If named arguments can only
use scalar values, why not drop the sigil?

    sub foo (:x, :y) { ... }

Curtis "Ovid" Poe
CTO, All Around the World
World-class software development and consulting

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