Arc Forumnew | comments | leaders | submitlogin
Strange coercion from string to int or num
8 points by rincewind 6068 days ago | 5 comments
try this:

  (type (coerce "2.2" 'int))
  (coerce "2.2" 'num)
on my computer, the first expression is evaluated to num, the second does not work at all.


6 points by pg 6068 days ago | link

That's a bug; thanks, will fix.

-----

2 points by sacado 6068 days ago | link

It looks like a bug... Anybody's got pg's email address :) ? He doesn't appear to come here very often, and if it really is a bug, that's the kind of feedback he said he really wanted...

-----

2 points by kens2 6068 days ago | link

I suspect that parsing a float (or complex) is a nonimplemented feature. According to my documentation http://arcfn.com/foundation-doc.html#coerce a string can be coerced to sym, cons, or int only.

-----

1 point by cchooper 6068 days ago | link

Well, parsing a float is implemented, in the sense that read will parse it for you, so that's not the problem. I suspect it doesn't work because num is just a place-holder for "this kind of number is not yet fully implemented; don't expect much". It will probably die in a future release.

-----

2 points by cchooper 6068 days ago | link

Oh well, I was wrong. It was a bug.

-----