The struct-id syntax class from syntax/parse/class/struct-id is puzzling
me.  Given this preamble:


(require (for-syntax syntax/parse/class/struct-id
                     syntax/parse
                     syntax/parse/experimental/template
                     ))

(struct person (name age height) #:transparent)

This works fine:

(define-syntax show-descript
  (syntax-parser
    [(_ id:struct-id) (template id.descriptor-id)]))
(show-descript person)



This is a compile-time error:

(define-syntax show-num-fields
  (syntax-parser
    [(_ id:struct-id) (template id.num-fields)]))
(show-num-fields person)

test.rkt:74:32: id.num-fields: attribute contains non-syntax value
  value: 3
  in: id.num-fields
  context...:
   /Applications/Racket_v6.11/collects/syntax/wrap-modbeg.rkt:46:4
   standard-module-name-resolver

I've played around with various versions of 'attribute', 'datum->syntax',
and 'quasitemplate / untemplate' but been unable to sort it out.  Can
someone explain it for me?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to