On 2009-Sep-19, at 5:53 am, Solomon Foster wrote:
On Sat, Sep 19, 2009 at 6:48 AM, Carl Mäsak <cma...@gmail.com> wrote:
David (>>>),
It sounds like the split personality of Ranges strikes again. I still think it makes more sense to have one Series-only type and one Range- only type,
rather than one Series type and one Range-plus-Series type.

If for no other reason than to contribute a contrasting viewpoint, I'm
not sure I see the problem in this case. A range is an object in Perl
6, in a much more palpable way than in Perl 5. This might be what
causes the mental mismatch for Perl5-ers.

Well, I wonder if the journey from a P5 point of view is the historical reason why we ended up with Range+series ".." and Series "...". Otherwise what's the rationale for having Range-:by separate from "..."?

As far as I can see, the range object already is of your proposed Range-plus-Series type,

But that's the problem; I'm proposing there shouldn't be a Range-plus- Series type, because it mixes two different concepts. As a range it works one way (basically representing an ordered pair of endpoints), but if you use :by() it looks like a discrete list... even though really it still is "just" a Range object.

and when I apply list context to the range, I get your proposed Series-only type (which happens to be an ordinary list, but still).

I think a Range shouldn't turn into a list, at least not implicitly. Some ranges have an obvious coercion (e.g. "a".."c" becomes <a b c>), but some don't (e.g. 1..5, which should encompass all nums between 1 and 5, not just the Ints. Unless we distinguish Int(1)..Int(5) from Num(1)..Num(5), which only raises the potential for confusion).

The one thing that worries me about this is how :by fits into it all.
rakudo: given 1.5 { when 1..2 { say 'between one and two' }; say 'not'; };
        rakudo: given 1.5 { when Range.new(from => 1, to => 2, by => 1/3) {
makes me very leery. I know :by isn't actually implemented yet, but what should it do here when it is?

Exactly: 1.5 is "between" 1 and 2, but if you're counting by thirds, 1.5 is not in the list(1..2 :by(1/3)). Sure, we can stipulate that this is simply how the rules work, but people are still going to get confused. On the other hand, we can get rid of the list/series/:by part of Ranges without losing any power (move that capability to ... instead), and cut down on the confusion.


-David

Reply via email to