develooper Front page | perl.perl6.language | Postings from December 2008

why infix:<div>:(Int, Int --> Rat)

Thread Next
From:
TSa
Date:
December 4, 2008 08:42
Subject:
why infix:<div>:(Int, Int --> Rat)
Message ID:
49380861.8000207@vts-systems.de
HaloO,

I realized from the typed literal thread that S03 now explicitly states
that div on two Ints returns a Rat. I remember the state of affairs
being that it returns an Int that adheres to the division of an Int $y
by another Int $x such that

      $y == ($y div $x) * $x + ($y mod $x)

holds with floor semantics as the default. This is now not the case
anymore. Why?

Isn't the special handling of integer division by infix:</> enough?
There the result becomes a Num only if needed such that it preserves
precision as long as possible. Question: does such a 'Num but Rat' type
dispatch to the Rat versions of operators?

Regards, TSa.
-- 

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About