# Capture Literals

```How would I construct a capture literal that has both an invocant and
at least one positional argument?  How do I distinguish this from a
capture literal that has no invocant and at least two positional
arguments?```
```
Gut instinct: if the first parameter in a list is delimited from the
rest using a colon instead of a comma, treat it as the invocant;
otherwise, treat it as the first positional argument.

This would mean that the rules for capturing are as follows:

* Capturing something in scalar context: If it is a pair, it is
captured as a named argument; otherwise, it is captured as the
invocant.

* Capturing something in list context: Pairs are captured as named
arguments; the first non-pair is captured as the invocant if it is
followed by a colon, but as a positional argument otherwise; all other
non-pairs are captured as positional arguments.

So:

\$x = /\$a;      # \$\$x eqv \$a
\$x = /:foo;    # %\$x eqv { foo => 1 }
\$x = /(\$a,);   # @\$x eqv ( \$a ); is the comma neccessary, or are the
() enough?
\$x = /(\$a:);   # \$\$x eqv \$a
\$x = /(:foo);  # %\$x eqv { foo => 1 }; assuming that adverbs can go
inside ().
\$x = /(\$a, \$b)      # @\$x eqv (\$a, \$b)
\$x = /(\$a: \$b)      # \$\$x eqv \$a; @\$x eqv (\$b)
\$x = /:foo (\$a: \$b, \$c):bar<baz> <== \$d, \$e <== flag => 0; # results
on next three lines:
# \$\$x eqv \$a
# @\$x eqv (\$b, \$c, \$d, \$e)
# %\$x eqv { foo => 1, bar => 'baz', flag => 0 }

Note that this approach makes it impossible for a pair to end up
anywhere other than as a named argument in the capture object; while
this makes sense when the capture object is being used as a proxy
argument list, it makes less sense when it is being used as the
equivalent of perl 5's references, and thus is probably a bug.

--
Jonathan "Dataweaver" Lang
```