Arc Forumnew | comments | leaders | submitlogin
1 point by rntz 5635 days ago | link | parent

It's more or less what coerce means.


2 points by CatDancer 5635 days ago | link

In arc3 I can already ask 'coerce to convert something for me into some general type and get back a more specific subtype:

  arc> (type (coerce "0" 'num))
  int
Maybe that's ok.

-----

1 point by rntz 5635 days ago | link

Hm. I wasn't thinking of it in terms of sub- and super-types, but in that context it makes sense. Thinking this way, if 'int is a subtype of 'num, then (isa 2 'num) should ideally return t; unfortunately it's nil in the present arc. :( I guess we'll just have to chalk arc's handling of types up as a bit of leaky abstraction and leave it be. I'll go push a fix for (coerce 0 'num) to anarki.

-----

2 points by CatDancer 5635 days ago | link

  (def isa (x y)
    (or (is (type x) y)
        (and (is y 'num) (is (type x) 'int))))

  arc> (isa 34 'num)
  t
On the one hand, this seems like the "right" answer, on the other hand, so far I've haven't needed this.

-----