James Cloos wrote:
"Michael" == Michael Zedeler <mich...@zedeler.dk> writes:

Michael> The Range 1.0001 .. 2.15 makes sense as an interval definition, but
Michael> there can hardly be a useful list definition without defining a step
Michael> size, at least, making it possible to use step sizes less than one.

The obvious (default) choice for a step size would be the precision of
the more precise of the two values.  So 0.0001 in your example above.
Well... maybe. How do you specify the intended precision, then? If I want the values from 1 to 2 with step size 0.01, I guess that writing

1.00 .. 2.00

won't be sufficient. Trying to work out the step size by looking at the precision of things that are double or floats doesn't really sound so feasible, since there are a lot of holes in the actual representation, so 1.0001 may become 1.0, yielding very different results.

It could be really nice to come up with something dwimmy, but I can't really se any really good candidates, when it comes to floating point numbers and strings.
If they were specified in hex float syntax, such as 0x1.01P0 .. 0x3.123P0,
then the (default) step should be 0x0.001P0 (which is the same as saying
1.00390625 .. 3.071044921875 with a step size of 0.000244140625).
Fair enough, but again - I guess they are translated straight to some internal representation where the information in this notation would be lost. Just like it would be in decimal notation.
Michael> Complex .. Complex -> undef, exception or some other bad thing.

Complex .. Complex should have a defined meaning in p6.

A definition which is easy to compute would be the set of points
contained by the square which has opposite corners at the two
specified points.
But is that useful? Complex numbers are mostly for mathematics, so I guess we have to look in that domain for a good use case. In that domain there is no natural ordering of complex numbers, and without some ordering, you may be able to decide what should be in the list to return, but not which order to use.

I believe that anything we put into Perl 6 should have obvious use cases and fall natural into place in the domain that the construct in question belongs to. This means we have to come up with a design (there currently is no specification of Complex .. Complex), some kind of use case to as justification and finally a validation that ensures that the design is consistent with other things in the language.

An example of an obvious inconsistency is ranges on strings compared to how cmp works.
A better definition would be the set of points contained by the
circle which has a diameter running between the two points.
In that case, you'd really need a step size, since circles tend bend :-) Also, I'd like to see an obvious and intuitive ordering.
In both cases, of course, including the points actually on the
1-manifold.

Either choice has the same meaning on the real axis as .. generates
when given real args, and is useful for interval arithmetic.
Something for which p6 is well suited.
I'll go and get my old topology book and see what I can find there, but I must admit that I'd prefer if Complex .. Complex was left undefined in the Perl 6 core, leaving it up to anyone to specify it later.

Regards,

Michael.

Reply via email to