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

Hmm... I haven't looked at the whole context of what you're doing. but I see you said "The macrolet conversion is where I am having difficulties." That makes sense. Arc doesn't have macrolet! (I think even Anarki doesn't have it... does it?)

Generally, I'd try to convert (macrolet ...) into local functions instead of local macros.

I don't know Common Lisp very well, but judging by the "surprising" example at http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node85.html, maybe there was no particular reason for this example to use (macrolet ...) in the first place:

   (defmacro! ichain-intercept (&rest body)
     `(let ((,g!indir-env this))
        (setq this
          (lambda (&rest ,g!temp-args)
            (block ,g!intercept
  -           (macrolet ((intercept (v)
  -                       `(return-from
  -                          ,',g!intercept
  -                          ,v)))
  +           (flet ((intercept (v)
  +                    (return-from
  +                      ,g!intercept
  +                      v)))
                (prog1
                  (apply ,g!indir-env
                         ,g!temp-args)
                  ,@body)))))))
(I haven't tested this.)

At this point, the code can be translated to Arc, and then it can be simplified dramatically:

  (point ,intercept
    (let intercept (fn (v) (,intercept v))
      ...))
  
  -->
  
  (point ,intercept
    (let intercept ,intercept
      ...))
  
  -->
  
  (point intercept
    ...)
This ends up simplifying to the exact same code as ichain-intercept%.

I think that makes sense. This example only accomplished the convenience of writing (intercept acc) instead of (return-from intercept acc), but your Arc code already had (intercept acc) to begin with.