On Sun, Mar 08, 2009 at 09:36:17PM +0100, Moritz Lenz wrote: : Currently the spec says: : : C<map> returns a lazily evaluated list which is comprised of : the return value of the expression, evaluated once for every : one of the C<@values> that are passed in. : : But both pugs and rakudo respect the arity of the code ref passed to it, : so that (1..6).map({$^a + $^b + $^c}) returns the list (6, 15), which is : very nice and very DWIM'my. : : But it opens the question what should happen if there is a number of : items in the list that's not easily divisible by the arity - should the : rest just be padded with undef's? or just ignored? Or fail() with a : friendly error message? : : I don't really mind either way, just want to test and implement it : correctly.
I think the basic rule has to be simply can the signature bind to the remaining arguments. If not, we get a warning on unused arguments. We can mark arguments as optional if that's what we mean. About the only thing I see to decide is whether the 2nd and subsequent placeholders consider themselves optional parameters. Is it better to get a single warning earlier when some arguments go unused, or is it better to assume the subsequent code can handle undefined paramets, with the likely result of more undefined access warnings later on? My gut feeling is that placeholder variables probably should not be considered optional; in most cases a non-divisible number of arguments indicates a logic error in the program, and an earlier message is better, even at the expense of thowing away some (possibly valid) partial data. Especially since we do have a way to indicate that partial data is acceptable: -> $a, $b?, $c? { $a + ($b//0) + ($c//0) } Larry