On 11/26/2015 03:36 PM, Wenzel P. P. Peppmeyer wrote:

On Thu, 26 Nov 2015, Elizabeth Mattijsen via RT wrote:

(0.1 .. 0.3).roll(10).say;

What did you expect?  a selection of 0.1, 0.2, 0.3 ??  or 10 random
values between 0.1 and 0.3 inclusive?

I would (naive) expect 10x a value between 0.1 and 0.3 . Analog to:

(0.1, 0.2, 0.3).roll(10).say;
# OUTPUT«(0.3 0.2 0.1 0.2 0.1 0.2 0.3 0.2 0.2 0.1)␤»

However, S03 is quite clear how Range is iterating.

0.1.succ == 1.1;

So incrementing by 0.1 can't work. It may be reasonable to fail as early
as possible for Range.roll on any Range that is neither Int nor Str on
both end points.

I don't think so. What's wrong with (1.1 .. 10.1).roll for example? It has well-defined semantics.

People need to read docs occasionally, there's nothing we can do to prevent them from abusing the core APIs, except by crippling them -- which isn't traditionally perl's approach.


Cheers,
Moritz

Reply via email to