From: Norbert_Paul on
Thomas A. Russ wrote:
> (defmacro myfor (X Y ACTION Z)
> (if (equal Z 'END)
> `(iter (for i from ,X to ,Y) (,ACTION i))
> (error "~% ERROR: not a proper syntax")))
>
> Now in this macro, you are safe using "I" as a variable because you
> don't really put any code from the user inside the binding of I. All
> you allow are ITER actions that are presumably simply symbols.

I'd say this is wrong, as ACTION could also be a lambda expression which
supposedly uses i within some closure outside the use of myfor:

(let ((i "Hello World"))
(myfor 0 9 (lambda (x) (terpri) (princ i)) END))

Norbert
From: Francogrex on
On Jul 29, 10:06 am, Kenneth Tilton <kentil...(a)gmail.com> wrote:
> Your "syntax" is "all uses must end in end? That seems more irritating
> than syntactical.

It's because I made a bet with some friend that i would reproduce in
lisp the syntax of the statistical software he uses, there loops end
with and end; It's just a test, I'll need to write a parser also.
From: Thomas A. Russ on
Norbert_Paul <norbertpauls_spambin(a)yahoo.com> writes:

> Thomas A. Russ wrote:
> > (defmacro myfor (X Y ACTION Z)
> > (if (equal Z 'END)
> > `(iter (for i from ,X to ,Y) (,ACTION i))
> > (error "~% ERROR: not a proper syntax")))
> >
> > Now in this macro, you are safe using "I" as a variable because you
> > don't really put any code from the user inside the binding of I. All
> > you allow are ITER actions that are presumably simply symbols.
>
> I'd say this is wrong, as ACTION could also be a lambda expression which
> supposedly uses i within some closure outside the use of myfor:
>
> (let ((i "Hello World"))
> (myfor 0 9 (lambda (x) (terpri) (princ i)) END))

Correct, if you can pass arbitrary forms in as the ACTION then you do
need to worry about this. If you are limited to certain iterate
supported forms that are atomic, then you don't.

--
Thomas A. Russ, USC/Information Sciences Institute