Arc Forumnew | comments | leaders | submitlogin
Num surprises me
4 points by garply 5584 days ago | 1 comment
(is (num 0.1) (coerce 0.1 'num)) -> nil

Also, when I see (type (/ 1 10)) -> num, I expect (is (/ 1 10) (num (/ 1 10))) -> t.

Perhaps num should be defined as the coercion above and the current string-formatting procedure that it is should be named as something else - numstr?



1 point by coconutrandom 5584 days ago | link

  arc> (load "erp.arc")
  nil
  arc> (is (erp:num 0.1) (erp:coerce 0.1 'num))
  (num 0.1): ".1"
  (coerce 0.1 (quote num)): 0.1
  nil
  arc> (is (erp:/ 1 10) (erp:num (/ 1 10)))
  (/ 1 10): 1/10
  (num (/ 1 10)): ".1"
  nil

Hmm, so neither 0.1 nor 1/10 is ".1"

I'm not sure what is supposed to happen but it's interesting.

-----