HaloO,

Luke Palmer wrote:
When do we do integer/rational math and when do we do floating point math?

Since we have now flooring semantics on modulus and division I wonder
how the coercion of nums to ints takes place. Does it also use floor?
E.g. is @array[-0.3] accessing the last element or is it truncating
to zero and indexing from the front?


Another integer issue is how the ++ and -- operators behave. Do they
coerce to int before the operation or do they keep nums as nums?
E.g.

  my $x = 3.25;
  $x++;  # 4.25 or 4?
  $x = -2.25;
  $x--;  # -3.25 or -4 or -3?


How are coercions handled when calling functions?

  sub identity ( Int $i ) { return $i }

  my Num $x = 3.25;

  say indentity($x); # prints 3 or type error? Or even 3.25?

I'm opting for type error on the footing that Int <: Num and
you can't allow a supertype where a subtype is expected.


BTW, are character positions integers or can we have fractional
characters on a higher unicode level that is a sequence of lower
level chars?


Regards, TSa.
--

Reply via email to