A question.

In a project of mine I'm looking to use Perl 6 Range values to represent continuous interval values in the most generic manner possible, meaning that the endpoint values could literally be of any type at all.

I just wanted to confirm that that would work in the general case, where I might want to do nothing more than:

  my $a = $b .. $c;
  my $a = $b ^.. $c;
  my $a = $b ..^ $c;
  my $a = $b ^..^ $c;

... plus invoke methods of $a to extract the values $b,$c and indicators of whether $b or $c are included within the range or not (how you read the distinction between the presence or absence of either or both "^".

As long as I don't try to iterate the range or something, I would expect the above to work for any possible value of $b or $c; for a realistic example:

  my $a = ['Foo', 17] ^.. ['Foo', 23];

... I would expect $a to be a Range and to be able to get those arrayrefs out of it.

On a tangent, it would be nice if Range were parameterizable like Seq say; such 
as:

  has Range of Int $foo;

... and then $foo would only accept Range values whose endpoints are Int.

Now in order for what I ask to work, Range has to be lazy enough that it won't for example test that $b is before $c when constructing the Range object, and will only complain if necessary when you try to use it where that matters.

Bottom line, is my example line with the "['Foo',17]" valid Perl 6 or not, and if not then what could be done about it?

Also, in what Synopsis is it documented what the methods are to extract the endpoints et al from a Range object. Or what are they called?

Thank you in advance.

-- Darren Duncan

Reply via email to