I'm reading it a bit at a time on lunch break, thanks for sending it along,
it's educational.

My comments here are all about the example on the top of page 5, starting
with the minutest. First a typo, it says "subC" where it should say "sumC"

multi sub sumB is ambiguous, due to your use of ";;" there. And sumI
*should* be ambiguous, because the caller sumC(Int $x ;; $y) {sumI($x,$y)}
means sumI will always be called with $x -> Int and varying $y. That
example could use a little re-working.

Note to Rakudo-porters: Can the error message "remember" the ";;" in the
sig ? The message from Rakudo * has a ","  where the source has ";;" which
is misleading:
Ambiguous call to 'sumB'; these signatures all match:
:(Bool $y, Bool $x)
:(Bool $y, Int $x)

The comment & example about "considering anonymous multi definitions in the
same block to define the same anonymous function" does show the feature's
desirability, but that proposed syntax might be problematic. (Deciding if &
how to make that part of the syntax is not in the scope of the paper, but
since you brought it up....) What if one wants to define two different
anonymous multi subs in the same scope? A contrived example:

sub pick_multi (Bool $p) {
  my multi sub hmmI(Int $y) { 2 * $y }
  my multi sub hmmI(Bool $y) { $y }

  my multi sub hmmB(Int $y) { 1 + $y  }
  my multi sub hmmB(Bool $y) { ! $y }

  $p ?? &hmmI !! &hmmB
}

Yes, one could enclose each anon-multi-set in a "do" block, but it feels to
me that defining an anonymous multi-sub should require a single statement,
to avoid unintentional co-mingling within a block.

Reply via email to