unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* why args are invalid syntaxes in syntax-rules
@ 2007-10-13  6:37 Marco Maggi
  2007-10-14 19:04 ` Stephen Compall
  0 siblings, 1 reply; 4+ messages in thread
From: Marco Maggi @ 2007-10-13  6:37 UTC (permalink / raw)
  To: guile-user

Ciao,
  trying this:

(define-module (hurt-me)
  #:use-module (ice-9 syncase))

(define-syntax this
  (syntax-rules ()
    ((_ ?body ?handler)
     (catch #t ?body ?handler))))

(this (lambda ()
	(display 'ciao)
	(newline))
      (lambda (key . args)
	#f))

(define-syntax that
  (syntax-rules (body handler)
    ((_ (body ?args ?body)
	(handler ?handler-args ?handler))
     (catch #t
       (lambda ?args
	 ?body)
       (lambda ?handler-args
	 ?handler)))))

(this (body ()
	(display 'ciao)
	(newline))
      (handler (key . args)
	#f))

I get:

  ERROR: invalid syntax ()

from the first argument to BODY; if I change
'body ()' to 'body (a b)' the error becomes:

  ERROR: invalid syntax (key . args)

Why there is no error when using LAMBDA
but there is with custom keywords?

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why args are invalid syntaxes in syntax-rules
  2007-10-13  6:37 Marco Maggi
@ 2007-10-14 19:04 ` Stephen Compall
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Compall @ 2007-10-14 19:04 UTC (permalink / raw)
  To: Marco Maggi; +Cc: guile-user


[-- Attachment #1.1: Type: text/plain, Size: 539 bytes --]

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

-- 
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
"Peta" is Greek for fifth; a petabyte is 10 to the fifth power, as
well as fifth in line after kilo, mega, giga, and tera.
  -- Lee Gomes, performing every Wednesday in his tech column
     "Portals" on page B1 of The Wall Street Journal

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why args are invalid syntaxes in syntax-rules
@ 2007-10-17 18:49 Marco Maggi
  2007-10-18 21:21 ` Neil Jerram
  0 siblings, 1 reply; 4+ messages in thread
From: Marco Maggi @ 2007-10-17 18:49 UTC (permalink / raw)
  To: guile-user

"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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why args are invalid syntaxes in syntax-rules
  2007-10-17 18:49 why args are invalid syntaxes in syntax-rules Marco Maggi
@ 2007-10-18 21:21 ` Neil Jerram
  0 siblings, 0 replies; 4+ messages in thread
From: Neil Jerram @ 2007-10-18 21:21 UTC (permalink / raw)
  To: Marco Maggi; +Cc: guile-user

"Marco Maggi" <marco.maggi-ipsu@poste.it> writes:

> |(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))

FWIW: I just tried that (with CVS HEAD, and with a preceding
`(use-syntax (ice-9 syncase))'), and it worked for me.

Regards,
        Neil



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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-10-18 21:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-17 18:49 why args are invalid syntaxes in syntax-rules Marco Maggi
2007-10-18 21:21 ` 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

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).