On Tue, Oct 04, 2022 at 03:40:59PM +0200, Ovid wrote: > Reviving an old discussion ... > > On Mon, Jan 31, 2022 at 9:50 PM Dave Mitchell <davem@iabyn.com> 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) { ... } I'd expect :@bar to be a syntax error. But note that in a separate proposal, a \@ary parameter auto-dereferences and aliases a passed array ref, as in sub foo(\@numbers) { say "@numbers" } foo([1,2,3]); # prints "1 2 3" This can be combined separately with named parameters, giving sub foo(\:@numbers) { say "@numbers" } foo("numbers => [1,2,3]); # prints "1 2 3" -- "Strange women lying in ponds distributing swords is no basis for a system of government. Supreme executive power derives from a mandate from the masses, not from some farcical aquatic ceremony." -- Dennis, "Monty Python and the Holy Grail"Thread Previous | Thread Next