SMOP Capture Expansion: Revision 1
Capture expansion means taking different objects and using them as part of the actual capture of a call. That means that the number of positional arguments, as well as the set of named arguments might not be determined at compile time.
The syntax for that is:
bar(|$capture_object, |@positional_arguments, |%named_arguments)
When using |$capture_object, the object must be of the Capture type, when using |@positional and |%named, a new capture object needs to be created and used.
Mixing several captures
When mixing different capture objects, the positional argument order must be preserved and named arguments conflict should raise warnings. Additionally, the mixing of inline arguments with capture expansion should produce other capture objects that will then be mixed together...
bar($a, |$b, $c, |@d, :foo<bar>, $e, |%f)
In that case, in order to preserve positional order, as well as preserve the priority on named arguments definition (the last overwrite the first, raising a warning), we need to actually create 6 different capture objects and mix them in the correct order:
my $c1 = \($a); my $c2 = \($c); my $c3 = \(:foo<bar>, $e); bar(|$c1, |$b, |$c2, |@d, |$c3, |%f)