problem-solving icon indicating copy to clipboard operation
problem-solving copied to clipboard

Making a signature accept a list of Pairs

Open FCO opened this issue 5 years ago • 2 comments

https://colabti.org/irclogger/irclogger_log/raku?date=2020-04-20#l387

m: sub a([$a]) { dd $a }; a [1]; a [1 => 2]
23:35 C<camelia> combined, experimental evalbot rakudo-moar b0a720cb6: OUTPUT: «1␤Too few positionals passed to 'a'; expected 1 argument but got 0 in sub-signature␤  in sub a at <tmp> line 1␤  in block <unit> at <tmp> line 1␤␤»

FCO avatar Apr 21 '20 00:04 FCO

I think having List.Capture automatically promote any Pair in the list into a named argument was probably a mistake (one of mine too, maybe I need to borrow rule 2 for a moment... :-))

The remaining question is how we can change this without inflicting breakage. There's two scenarios:

  1. We try and change it. We blin it. We find nothing at all depended on the current semantics. We say, eh, cheating is technique, and just change it.
  2. We start passing a named argument to .Capture in signature binding to indicate old vs. new semantics, depending on the language version the signature shows up in.

jnthn avatar May 06 '20 21:05 jnthn

Ah, and I hereby delegate the research to find out which of 1 or 2 we have to do, to somebody enthusiastic about it. :-)

jnthn avatar May 06 '20 21:05 jnthn