[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: why args are invalid syntaxes in syntax-rules
From: |
Marco Maggi |
Subject: |
Re: why args are invalid syntaxes in syntax-rules |
Date: |
Wed, 17 Oct 2007 20:49:50 +0200 |
"Stephen Compall" wrote:
>On Sat, 2007-10-13 at 08:37 +0200, Marco Maggi wrote:
>> (body ?args ?body)
>
>First, invoke that instead of this. Second, does the above
pattern
>match the below syntax?
>
>> (body ()
>> (display 'ciao)
>> (newline))
Thanks and sorry, I did multiple errors in converting the
real code into an example. The correct example syntax is:
|(define-syntax that
| (syntax-rules (body handler)
| ((_ (body ?body ...)
| (handler ?handler-args ?handler ...))
| (catch #t
| (lambda ()
| ?body ...)
| (lambda ?handler-args
| ?handler ...)))))
|
|(that (body
| (display 'ciao)
| (newline))
| (handler (key . args)
| #f))
and for the curious the real code is (now fixed, I hope):
|(define-syntax with-deferred-exceptions
| (syntax-rules (exception-handler
deferred-exception-handler lambda begin)
|
| ((_ (lambda () ?body ...)
| (lambda ?handler-args ?handler ...)
| (lambda ?deferred-args ?deferred-handler ...))
| (with-fluids ((*gee-deferred-exceptions* '()))
| (gee-K (catch #t
| (lambda () ?body ...)
| (lambda ?handler-args (deferred-catch
?handler ...)))
| (run-deferred-exceptions-handler
| (lambda ?deferred-args ?deferred-handler
...)))))
|
| ((_ (begin ?body ...)
| (exception-handler ?handler-args ?handler ...)
| (deferred-exception-handler ?deferred-args
?deferred-handler ...))
| (with-deferred-exceptions
| (lambda () ?body ...)
| (lambda ?handler-args ?handler ...)
| (lambda ?deferred-args ?deferred-handler ...)))
|
| ((_ (begin ?body ...) ?first ?form ...)
| (with-deferred-exceptions (begin ?body ... ?first)
?form ...))
|
| ((_ ?first ?form ...)
| (with-deferred-exceptions (begin ?first) ?form ...))))
which accepts both the forms:
|(with-deferred-exceptions
| (this)
| (that)
| (exception-handler (key . args)
| (do-some-thing))
| (deferred-exception-handler (key . args)
| (do-some-other-thing)))
|
|(with-deferred-exceptions
| (lambda ()
| (this)
| (that))
| (lambda (key . args)
| (do-some-thing))
| (lambda (key . args)
| (do-some-other-thing)))
converting the first into the second, and eventually into:
|(with-fluids ((*gee-deferred-exceptions* '()))
| (gee-K (catch #t
| (lambda () (this) (that))
| (lambda (key . args) (deferred-catch
(do-some-thing))))
| (run-deferred-exceptions-handler
| (lambda (key . args) (do-some-other-thing)))))
--
Marco Maggi
"Now feel the funk blast!"
Rage Against the Machine - "Calm like a bomb"