define-macro -> define-syntax 
Author Message
 define-macro -> define-syntax

I'm looking for a (general) way of how to convert a define-macro definition
(R4RS) to define-syntax (Chez Scheme). For example I want to use "amb" with
Chez.

(define-macro amb
  (lambda alts...
    `(let ((+prev-amb-fail amb-fail))
       (call/cc
        (lambda (+sk)

                   `(call/cc
                     (lambda (+fk)
                       (set! amb-fail
                         (lambda ()
                           (set! amb-fail +prev-amb-fail)
                           (+fk 'fail)))
                       (+sk ,alt))))
                 alts...)
          (+prev-amb-fail))))))

...Christian



Mon, 06 Oct 2003 22:28:42 GMT  
 define-macro -> define-syntax


Quote:
>I'm looking for a (general) way of how to convert a define-macro definition
>(R4RS) to define-syntax (Chez Scheme). For example I want to use "amb" with
>Chez.

>(define-macro amb
>  (lambda alts...
>    `(let ((+prev-amb-fail amb-fail))
>       (call/cc
>        (lambda (+sk)

>                   `(call/cc
>                     (lambda (+fk)
>                       (set! amb-fail
>                         (lambda ()
>                           (set! amb-fail +prev-amb-fail)
>                           (+fk 'fail)))
>                       (+sk ,alt))))
>                 alts...)
>          (+prev-amb-fail))))))

>...Christian

Hi.  I was planning to answer your email shortly --
after getting my c.l.s. "fix".  :) Here is the
answer.

(define-syntax amb
  (syntax-rules (amb-fail)
    ((amb alt ...)
     (let ((+prev-amb-fail amb-fail))
       (call/cc
         (lambda (+sk)
           (call/cc
             (lambda (+fk)
               (set! amb-fail
                 (lambda ()
                   (set! amb-fail +prev-amb-fail)
                   (+fk 'fail)))
               (+sk alt)))
           ...
           (+prev-amb-fail)))))))

I think amb-fail doesn't really need to be a keyword, but
it doesn't hurt.

--d



Mon, 06 Oct 2003 23:24:25 GMT  
 define-macro -> define-syntax
Thanks for the quick reply! It works!!! (... and bag-of, too.) I'm very
happy! ...Christian



Quote:


> >I'm looking for a (general) way of how to convert a define-macro
definition
> >(R4RS) to define-syntax (Chez Scheme). For example I want to use "amb"
with
> >Chez.

> >(define-macro amb
> >  (lambda alts...
> >    `(let ((+prev-amb-fail amb-fail))
> >       (call/cc
> >        (lambda (+sk)

> >                   `(call/cc
> >                     (lambda (+fk)
> >                       (set! amb-fail
> >                         (lambda ()
> >                           (set! amb-fail +prev-amb-fail)
> >                           (+fk 'fail)))
> >                       (+sk ,alt))))
> >                 alts...)
> >          (+prev-amb-fail))))))

> >...Christian

> Hi.  I was planning to answer your email shortly --
> after getting my c.l.s. "fix".  :) Here is the
> answer.

> (define-syntax amb
>   (syntax-rules (amb-fail)
>     ((amb alt ...)
>      (let ((+prev-amb-fail amb-fail))
>        (call/cc
>          (lambda (+sk)
>            (call/cc
>              (lambda (+fk)
>                (set! amb-fail
>                  (lambda ()
>                    (set! amb-fail +prev-amb-fail)
>                    (+fk 'fail)))
>                (+sk alt)))
>            ...
>            (+prev-amb-fail)))))))

> I think amb-fail doesn't really need to be a keyword, but
> it doesn't hurt.

> --d



Tue, 07 Oct 2003 00:58:54 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Macros defining macros with define-syntax

2. define-macro vs define-syntax

3. is define-syntax inside define-syntax OK?

4. Scheme macro source: define/keyed, for defining keyword-triggered arguments

5. shadows of define and define-syntax

6. define in define-syntax

7. defmacro/define-macro using syntax-case

8. Question about a macro-defining macro

9. Macro-Defining Macros

10. help sought for macro defining macro

11. Load-time problem with a macro that defines a macro

12. define-syntax must be followed by syntax-rules ??

 

 
Powered by phpBB® Forum Software