Arc Forumnew | comments | leaders | submitlogin
4 points by skenney26 5741 days ago | link | parent

In the definition of check a uniq is assigned the value of expr to avoid multiple evaluation. Therefore, expr is evaluated before test. It's a good idea to order arguments in the same order they are evaluated.

Section 10.2 (page 135) in On Lisp (http://paulgraham.com/onlisp.html) discusses why order of evaluation can sometimes be an issue.



3 points by silence 5741 days ago | link

Thanks for that reference.

Check is currently defined like this:

  (mac check (x test (o alt))
    (w/uniq gx
      `(let ,gx ,x
         (if (,test ,gx) ,gx ,alt))))
Can the order of evaluation problem be corrected by changing the check macro to the following?

  (mac check (test x (o alt))
    (w/uniq gx
      `(let ,gx nil
          (if (,test (= ,gx ,x)) ,gx ,alt))))

-----

3 points by skenney26 5741 days ago | link

Interesting twist. I don't immediately see any issues with doing it that way (other than making the definition slightly longer).

-----