Jon Lang wrote:
smuj wrote:
I'd personally prefer it if Ranges just did lists, including when smart
matching, but had an interval method or such like for explicit matching
against the endpoints, e.g.

2.5 ~~ interval(1..5)   # or
2.5 ~~ $myrange.interval

I don't like the Huffman encoding: "does $x come after $a and before
$b?" is a common test, and so should be short.  I'd rather require you
to force it into list context if your goal is to test for set
membership.  In fact, that might be a clean way of handling its dual
nature: in item context, it behaves as a Range object; in list
context, it behaves as the RangeIterator.  So:

    2.5 ~~ 1..5 # true: equivalent to "2.5 ~~ 1 <= $_ <= 5".
    2.5 ~~ @(1..5) # false: equivalent to "2.5 ~~ (1, 2, 3, 4, 5)".

Incidently, this first example is why I think that Range is intimately
related to the various order-related operators, and in particular
before and after: its most common use outside of generating sequential
lists is to provide a shorthand for "$min before $_ before $max" and
similar range-testing expressions.

So you're saying you'd like things to stay exactly as they are at the moment!? :-)


Reply via email to