[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: loop translations (was: Re: language translator help)
From: |
Clinton Ebadi |
Subject: |
Re: loop translations (was: Re: language translator help) |
Date: |
Mon, 29 Apr 2002 16:07:40 -0400 |
On Sunday 28 April 2002 14:48, Marius Vollmer wrote:
> Marius Vollmer <address@hidden> writes:
> > A good solution would be to make the continue feature optional and
> > let the user choose the name of the function. Much like
> > 'with-exit', where the name of the exiting function is determined by
> > the user, not the macro.
>
> And, of course, to use (ice-9 syncase) instead of define-macro.
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:
(define-syntax for
(syntax-rules ()
((for (var start end) ....)
(catch 'break
(lambda ()
(let loop ((var start))
(catch 'continue
(lambda ()
(cond ((<= var end)
...
(throw 'continue))))
(lambda ignored
(loop (+ var 1))))))
(lambda ignored
(if #f #f #f))))))
(well, I had one problem before that--with-mutex wasn't defined, and yes, I
did remember the --with-threads and I do have threading support, but I had to
add :use-module (ice-9 threads) to syncase.scm to work with Guile 1.7...maybe
this is a bug that others will experience?).
But when I try to load for.scm, I get this error:
ERROR: missing ellipsis in syntax form (syntax (catch (quote break) (lambda
() (let loop ((var start)) (catch (quote continue) (lambda () (cond ((<= var
end) ... (throw (quote continue))))) (lambda ignored (loop (+ var 1))))))
(lambda ignored (if #f #f #f))))
ABORT: (misc-error)
So, what are the rules for using ... exactly ? If I remove the parens around
(var start end), it almost works, instead I get:
guile> (load "for.scm")
guile> (for i 1 10 (display i))
1
Backtrace:
In current input:
3: 0* (for i 1 10 (display i))
3: 1 [catch break #<procedure #f ()> #<procedure #f syntmp-ignored-18>]
?: 2* [#<procedure #f ()>]
?: 3* [syntmp-loop-15 1]
?: 4 [catch continue #<procedure #f ()> #<procedure #f syntmp-ignored-17>]
?: 5* [#<procedure #f ()>]
?: 6* (cond ((<= syntmp-i-16 #) (<= syntmp-i-16 #) (throw #)))
?: 7* [<= 1 #<unspecified>]
<unnamed port>: In procedure <= in expression (<= syntmp-i-16 (display
syntmp-i-16)):
<unnamed port>: Wrong type argument in position 2: #<unspecified>
ABORT: (wrong-type-arg)
guile>
so it works for the first time, but then fails...the lack of documentation
about "new" macros doesn't help me either :-)
- Re: language translator help, (continued)
- Re: loop translations (was: Re: language translator help), Marius Vollmer, 2002/04/28
- Re: loop translations (was: Re: language translator help), John W. Eaton, 2002/04/28
- Re: loop translations (was: Re: language translator help), Marius Vollmer, 2002/04/28
- Re: loop translations (was: Re: language translator help), Marius Vollmer, 2002/04/28
- Re: loop translations (was: Re: language translator help),
Clinton Ebadi <=
- Re: loop translations (was: Re: language translator help), Eric E Moore, 2002/04/29
- Re: loop translations (was: Re: language translator help), Eric E Moore, 2002/04/30
- Re: loop translations (was: Re: language translator help), Neil Jerram, 2002/04/28
translators and scoping rules (was: Re: language translator help), John W. Eaton, 2002/04/27
Re: translators and scoping rules (was: Re: language translator help), Per Bothner, 2002/04/28
Re: translators and scoping rules (was: Re: language translator help), John W. Eaton, 2002/04/28