Arc Forumnew | comments | leaders | submitlogin
1 point by rocketnia 5129 days ago | link | parent

Here's a version of 'if that depends only on a built-in function and a built-in macro:

  (def fn-if (condition then else)
    ((if condition then else)))
  
  (mac if body
    (whenlet (first . rest) body
      (iflet (then . elses) rest
        `(fn-if ,first (fn () ,then) (fn () (if ,@elses)))
        first)))
These implementations are just for demonstration, since they depend on 'if themselves.


1 point by Pauan 5129 days ago | link

Huh, interesting. I think I'll implement it as a fexpr, though, both for consistency (with the other special forms) and simplicity.

-----