Arc Forumnew | comments | leaders | submitlogin
1 point by Pauan 4783 days ago | link | parent

Using err:string is good, but why the unnecessary `and` check? Am I missing something?


1 point by shader 4783 days ago | link

The and is required to make sure that a type was provided, otherwise it will always fail the type check. Also, if you leave n out of the and clause, it will still pass if the required type is sym. Maybe that should be fixed.

-----

1 point by Pauan 4783 days ago | link

Hm... yes, you're right. Odd, I remember it working fine when I tested it earlier. This should work correctly:

  (mac require (n (o t))
    `(if (no ,n)                  (err:string "parameter " ',n " is required")
         (and ,t (no:isa ,n ,t))  (err:string "parameter " ',n " must be of type " ,t)))

-----