1 point by akkartik 1797 days ago | link | parent Anarki lets you escape down to scheme, so I've been doing just:`````` (\$.inexact->exact (/ 3 2)) `````` Perhaps it's worth fixing this in coerce? Should exact or inexact be the default subtype for num?
 2 points by Pauan 1796 days ago | link "Should exact or inexact be the default subtype for num?"I see at least a few good solutions:1) Use floating point everywhere. This is what JavaScript (and Nulan) do. Simpler, but it means you give up exact math on rationals.2) Use floating point by default but support coercing to exact. This may or may not lose information, I don't know. Alternatively, support exact by default and coerce to floating point.3) Do things the way Racket does it, but when printing the number, coerce it to floating point. This is what Arc/Nu does:`````` > 3/2 1.5 `````` This has the benefit that math calculations are exact, but the result is printed in a more readable fashion (more readable to me anyways).-----
 1 point by akkartik 1796 days ago | link Thanks, I ended up going with the third option, but with a twist: display prints inexact but write prints exact. So at the prompt you still see exact numbers:`````` arc> (/ 3 2) 3/2 arc> (prn "aa: " (/ 3 2)) aa: 1.5 `````` https://github.com/nex3/arc/commit/a9dc15d701-----
 2 points by akkartik 1795 days ago | link Update: I just realized my print solution sucks:`````` arc> (prn (/ 3 2)) 1.5 arc> (prn (list (/ 3 2))) (3/2) `````` Rolling it back. Let's just explicitly use real for now.-----
 2 points by akkartik 1796 days ago | link Hmm, I thought about it some more, and it seems worth preserving exact because you lose information in going to inexact.The solution I ended up with was to use your name and Pauan's trick: https://github.com/nex3/arc/commit/4227a4a9b9.Now instead of`````` (coerce (/ 3 2) 'num) `````` You'd say:`````` (real (/ 3 2)) `````` What do you think? Easy to change if you prefer.-----