guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: loop translations (was: Re: language translator help)


From: Eric E Moore
Subject: Re: loop translations (was: Re: language translator help)
Date: Mon, 29 Apr 2002 21:50:10 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.2

Clinton Ebadi <address@hidden> writes:


[...]

> Which brings me to my problem...I tried to redefine the for macro as a 
> syncase macro (so I could add (break) and (continue) inside of the macro, 
> which wasn't working with define-macro)...and I have a problem:

[...]

> So, what are the rules for using ... exactly ? If I remove the parens around 
> (var start end), it almost works, instead I get:

Basically there needs to be a plain identifier before them, that needs
to appear before the corresponding ... in the replacement.  Rather
than thinking of the pattern think of the pattern <something> ... 

you want something more like:

(define-syntax for 
  (syntax-rules ()
    ((for (var start end) body ...)
     (catch 'break
       (lambda ()
         (let loop ((var start))
           (catch 'continue
             (lambda ()
               (cond ((<= var end)
                      body ...
                      (throw 'continue))))
             (lambda ignored
               (loop (+ var 1))))))
       (lambda ignored
         (if #f #f #f))))))


> so it works for the first time, but then fails...the lack of documentation 
> about "new" macros doesn't help me either :-)

The r5rs description is... less than transparant, I'll grant :)

-- 
Eric E. Moore

Attachment: pgptgpECnszuy.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]