[plt-scheme] Re (modified): macros that expand into LISTS OF top-level definitions with computed names

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Aug 14 11:54:37 EDT 2009

On second thought, this example is closer to what you need:

(define-syntax (def-all stx)
   (syntax-case stx ()
     [(_ type ...)
      (with-syntax ([(index ...) (build-list (length (syntax->list  
(syntax (type ...)))) add1)])
        #`(begin (define-values (type ...) (values index ...))
                 (register-instruction 'type)
                 ...))]))

(define (register-instruction x) x)

(def-all exec float integer)

exec float integer



On Aug 14, 2009, at 11:44 AM, Matthias Felleisen wrote:

>
> Will this help you along?
>
> #lang scheme
>
> (define-syntax (def-all stx)
>   (syntax-case stx ()
>     [(_ type ...)
>      #`(begin (begin (define type 1)
>                      (register-instruction 'type))
>               ...)]))
>
> (define (register-instruction x) x)
>
> (def-all exec float integer)
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.