Matt Diephouse writes: > The point that it's documented for C<param> and for C<return> doesn't > remove the fact that while this DWIM the majority of the time, it can > be the cause of a subtle bug. I'm sure many people don't know about > the DWIM behavior. Or aren't actively aware of it.
As is the case with many forms of DWIM. This is something we must always consider when adding a DWIMity. How could it subtly introduce bugs, or how could it be a pain? Some DWIMs become a major pain when you're dealing with generics, for instance, by requiring the user to duplicate the type switch used internally just go get consistent behavior. The one in Perl 5 that stands out most was the cause for the only patch I ever sent to p5p: the rand function. "rand $x" will give you a uniformly distributed random number in [0, $x) for any $x EXCEPT 0. If you say "rand 0", it gives you a random number between 0 and 1, which was supposed to be What I Meant. That led to code like this (Perl6ized as usual): my $num = $param == 0 ?? 0 : rand $param; Repeating the test that it did itself, just to get consistent behavior. We must be careful not to repeat mistakes like this in the design of Perl 6 [1]. Luke