Thanks Jens.  I was wondering whether syntax-case -- which I haven't yet come to grips with -- might hold some clues to writing macros more briefly and clearly, so your rewrite is welcome:

> Here is an alternative:
> 
> (define-syntax (for stx)
>   (define (template var list-expr bodies)
>     #`(map (lambda (#,var) #,@bodies) #,list-expr))
>   (syntax-case stx (in as)
>     [(for element in list body ...)
>      (template #'element #'list #'(body ...))]
>     [(for list as element body ...)
>      (template #'element #'list #'(body ...))]))

In this instance, however, it looks to me as if the amount of duplication has remained the same, while the apparent complexity -- #`, #,@, #'  -- has increased.  Compare with the earlier:

(define-syntax for
  (syntax-rules (in as)
    ((for element in list body ...)
     (map (lambda (element)
            body ...)
          list))
    ((for list as element body ...)
     (for element in list body ...))))
 
which I was hoping could be improved on.

Thanks again

Dan




