Arc Forumnew | comments | leaders | submitlogin
2 points by palsecam 5625 days ago | link | parent

In the definition of 'ar-type in ac.scm, change:

   ((integer? x) 'int)
by:

   ((and (integer? x) (exact? x))  'int)
Same file, definition of 'ar-coerce, change:

   ((integer? x) [...]
by:

   ((and (integer? x) (exact? x)) [...]
This leads to:

   (type 2) => int
   (type 2.0) => num
   (type 2.1) => num
   (coerce 2.0 'int) => 2
------

"It initially makes sense for 2.0 to be 'int since it can be losslessly coerced to an integer": mostly a question of personal taste but I don't agree.

"2.0" is not "2". An integer has no decimal part. If you want an integer, either you say "2" or you coerce "2.0" to 'int. In my view, the "integer" notion is when you're dealing with low level stuff (like in C) and at this level you don't want any cleverness (like 2.0 being an int because it is mathematically equals to 2).

The fix above makes it work like that (type of 2.0 is 'num).

Plus, there are languages (say, Python) in which:

   3 / 2.0 = 1.5
   3 / 2 = 1
Edit: and in Arc also it differs!:

  (/ 3 2.0)  => 1.5 
  (/ 3 2) => 3/2