Dave Whipp wrote:
> An Int is Enumerable: each value that is an Int has well defined succ
> and pred values. Conversely, a Real does not -- and so arguably should
> not support the ++ and -- operators. Amonst other differences, a
> Range[Real] is an infinite set, whereas a Range[Int] has a finite
> cardinality.

++ and -- aren't meant to increment or decrement to the next/last value
in the set, they're increment or decrement by one (see perlop). I can
see your point about them not making sense for Real since it's not an
enumerable set like integers but I don't think it would be in the
spirit of DWIM to have to do:

my Int $i = 5;
say ++$i;

and

my Real $i = 5; # Or Num, Float or whatever
say $i += 1;

as that would be both inconsistent  with Perl 5, C and every language
that has ++/-- as well as being internally inconsistent  in Perl 6 to
have to use different constructs to increment by one for different
number types.

There's of course the argument that ++/-- aren't needed at all since
they're really just relics from C where you needed them for pretty much
every loop, although they're definitely usable almost everywhere where
loop(;;) is appropriate in Perl 6 you don't need them as much as C,
some other languages such as Python and Ruby don't have them at all,
but that's a bit offtopic;)

> (perhaps this discussion belongs on p6l)

It sure does;)

Reply via email to