[racket-dev] can a syntax-class "inherit" attributes?

From: Stephen Chang (stchang at ccs.neu.edu)
Date: Fri Aug 23 00:22:59 EDT 2013

Is there a way for a syntax-class to automatically inherit attributes?

For example, the third class below combines the first two. Is there a
way to automatically get the attributes from the first two classes in
the third one (ie, I want to drop the "#:attr X #'a.X" part in the
third class)?

#lang racket
(require syntax/parse)

(define-syntax-class A (pattern (a b) #:attr X #'b))
(define-syntax-class B (pattern (a b c) #:attr X #'c))
(define-syntax-class AorB
  (pattern a:A #:attr X #'a.X)
  (pattern b:B #:attr X #'b.X))

(syntax-parse #'(list 1) [ab:AorB (attribute ab.X)])

Posted on the dev mailing list.