unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Marco Maggi" <marco.maggi-ipsu@poste.it>
To: "guile-user" <guile-user@gnu.org>
Subject: Re: why args are invalid syntaxes in syntax-rules
Date: Wed, 17 Oct 2007 20:49:50 +0200	[thread overview]
Message-ID: <JQ2KB2$496E3698023E397AEF9F77567434205A@poste.it> (raw)

"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"




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


             reply	other threads:[~2007-10-17 18:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-17 18:49 Marco Maggi [this message]
2007-10-18 21:21 ` why args are invalid syntaxes in syntax-rules Neil Jerram
  -- strict thread matches above, loose matches on Subject: below --
2007-10-13  6:37 Marco Maggi
2007-10-14 19:04 ` Stephen Compall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='JQ2KB2$496E3698023E397AEF9F77567434205A@poste.it' \
    --to=marco.maggi-ipsu@poste.it \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).