Autrijus Tang wrote:
    map { $_ => $_; } @foo;

This works too:

    map { ;$_ => $_ } @foo;

But () is still only a grouper, so this won't do:

    map { ($_ => $_) } @foo;

Does this make sense?

A lot! BTW, is it possible to distinguish methods and subs from the toplevel, too? That little inference might help to solve the topic versus invocant problem by not requiring to alias $_ to $?SELF.

I imagine

map { .foo } @objects;

to be interpreted as

map method { $?SELF.foo } @objects;

The distinguisher were the need of having a defined $?SELF in the
closure. My idea is the following:

        | number of |      as      |
class   | invocants |     multi    |
--------+-----------+--------------+
Sub     |     0     |  > 0         |
 $?SELF | undef     | := @?SELF[0] |
 @?SELF | undef     | invocants    |
--------+-----------+--------------+
Method  |     1     |  > 1         |
 $?SELF | invocant  | := @?SELF[0] |
 @?SELF | undef     | invocants    |
--------+-----------+--------------+

I used the @?SELF array mostly for illustrating my idea concerning
$?SELF, but it might be usefull for things like

multi sub foo
{
   # use @?SELF here
}

as a catch-all for an unspecified number of parameters of type Any.
The type of a method's $?SELF is derived from the lexical class scope.
Subs in a class are just scoped there. A multi sub in a class is also
just scoped there and the class has no impact on the specificity of
any of the parameter types.
--
TSa (Thomas Sandlaß)



Reply via email to