Arc Forumnew | comments | leaders | submitlogin
1 point by rntz 5666 days ago | link | parent

It encapsulates the notion of only evaluating a given set of expressions once. It's used for writing macros. An example is probably best:

    arc> (with (x '(x-expr) y '(y-expr)) (once-only (x y) `(+ ,x ,y ,y)))
    (with (g1838 (x-expr) g1839 (y-expr)) (+ g1838 g1839 g1839))
This is the equivalent of the handwritten:

    arc> (with (x '(x-expr) y '(y-expr))
           (w/uniq (gx gy) 
             `(with (,gx ,x ,gy ,y) (+ ,gx ,gy ,gy))))
    (with (g1840 (x-expr) g1841 (y-expr)) (+ g1840 g1841 g1841))