Arc Forumnew | comments | leaders | submitlogin
2 points by skenney26 6016 days ago | link | parent

Thanks for the help absz. I'm creating a variety of iterators for a graphics app and I just want to make sure they're being written correctly.

I still don't quite understand why v needs to be initialized. For example, the following definition seems to work fine:

  (mac for (v init max . body)
    (w/uniq gm
     `(let ,gm (+ ,max 1)
        (loop (set ,v ,init) (< ,v ,gm) (set ,v (+ ,v 1))
          ,@body))))


2 points by absz 6016 days ago | link

The problem is that if you define it this way, then your v is no longer lexical; instead, it's in the global namespace. Thus, writing (for ref 0 n (frob ref)) would overwrite the global ref procedure, which is not what you want.

-----

1 point by skenney26 6016 days ago | link

Ah, it finally makes sense. Thanks again.

-----