Arc Forumnew | comments | leaders | submitlogin
4 points by drcode 6116 days ago | link | parent

of course you can do this:

  (with (foo nil
         bar nil)
        (= foo [bar _])
        (= bar [+ 1 _])
        (foo 5))
That is the Right Way to solve this in arc, I think... Handles mutual recursion without problem. Easily wrappable in a macro, if desired.


3 points by cchooper 6116 days ago | link

You just beat me to it:

  (mac fwiths (defs . body)
    `(with ,(intersperse-nils (keep-odd-pos defs))
           ,@(make-setters defs)
           ,@body))

  (def keep-odd-pos (lst)
    (if lst (cons (car lst) (keep-odd-pos (cddr lst)))))

  (def intersperse-nils (lst)
    (if lst (cons (car lst) (cons nil (intersperse-nils (cdr   lst))))))

  (def make-setters (lst)
    (if lst (cons (list '= (car lst) (cadr lst)) (make-setters (cddr lst)))))

-----