For now, to distinguish 'foo(:named)' call from foo(:!named) or foo() the most appropriate construct is:
multi foo(:$named! where ? *) { ... }
multi foo(:$named! where ! *) { ... }
multi foo() { ... }
Which is performance-wise sub-optimal and not the easiest code to read.
Since we already have literal candidate support for positionals, why can't we have it for nameds?
multi foo(:named) { ... }
multi foo(:!named) { ... }
multi foo() { ... }
I'm not entirely clear on what you mean. Could you elaborate?
Here is a sample with positional:
multi foo('foo') { say "foo:foo" }
multi foo('bar') { say "foo:bar" }
foo(<foo>) # foo:foo
The example from the first comment works like this:
multi foo(:$named! where ? *) { say "foo :named" }
multi foo(:$named! where ! *) { say "foo :!named" }
multi foo() { say "foo" }
foo(:named); # foo :named
foo(:!named); # foo :!named
foo(); # foo
But it'd be way more readable to have it like this:
multi foo(:named) { say "foo :named" }
multi foo(:!named) { say "foo :!named" }
multi foo() { say "foo" }
foo(:named); # foo :named
foo(:!named); # foo :!named
foo(); # foo
So, my proposal bottom line is:
:named in a signature stands for required named parameter with a true value :!named respectively stands for a required named parameter with a false valueTo my view this should improve both readability and simplify optimization.
Most helpful comment
Here is a sample with positional:
The example from the first comment works like this:
But it'd be way more readable to have it like this:
So, my proposal bottom line is:
:namedin a signature stands for required named parameter with a true value:!namedrespectively stands for a required named parameter with a false valueTo my view this should improve both readability and simplify optimization.