Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 5218 days ago | link | parent

Hmm... my code originally looked a lot like that (except for naming and the implementation of 'unless-both). Then I edited my post quite a bit because I thought there was a problem with the (and (unless-both ...) (congruent-sigs ...)) expression. (I can't remember what it was now, and I think I was mistaken.)

So I added the 'either-way parameter, and then I moved the logic into a function to make the evaluation order more to my liking--no calling the test on 'x before 'y is evaluated--and it got to the complicated state it's in now. In fact, I see some bugs now; the place where it says "do.test.y (aand (ifneither)" should be "do.test.y nil (aand (do.ifneither)".

For whatever it's worth, here's 'ibona again, with your much better name, and without 'eitherway. The only thing that's really different from your version is the argument evaluation timing.

  (mac unless-both (test x y ifneither)
    `(fn-unless-both ,test ,x ,y (fn () ,ifneither)))
  
  (def fn-unless-both (test x y ifneither)
    (zap testify test)
    (if do.test.x  do.test.y
        do.test.y  nil
                   (do.ifneither)))
Thanks for your insight. ^_^