Are you intending to use the struct procedure names at compile time (such as in a macro) or runtime?
On Tuesday, October 26, 2021 at 5:02:46 PM UTC-7 [email protected] wrote: > I understand why structs are opaque, by default, but I want to discover > the public interface of some struct type, that is, a list of the procedures > defined by the struct. > > Here is an example. Suppose I want to find out all the procedures defined > on an instance of the syntax struct > > #'42 > > Dr. Racket shows an expander clicky that shows some formatted information > inside the instance : > > [image: Screenshot from 2021-10-26 16-51-37.png] > > Uncapitializing the names in the display reveals the interface: > > (syntax-position #'42) ~~> 790 > (syntax-span #'42) ~~> 2 > (syntax-original? #'42) ~~> #t > > etc. > > I want to discover those procedure names in my racket program, not > manually by visually inspecting graphics in Dr Racket. > > I found this trick for structs that I define: > > #lang racket > (require (for-syntax racket/struct-info)) > (require racket/pretty) > > (struct foo (a b)) > (begin-for-syntax > (displayln > (extract-struct-info > (syntax-local-value > #'foo)))) > > ~~> > > [image: Screenshot from 2021-10-26 16-59-19.png] > > but it doesn't work for the syntax type > > (begin-for-syntax > (displayln > (extract-struct-info > (syntax-local-value > #'syntax)))) > > ~~> > > [image: Screenshot from 2021-10-26 17-00-33.png] > > I'd be grateful for advice and an example of how to get the interface of > "syntax" without Dr Racket and without grovelling docs. > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/a7d7828e-7114-488c-877e-308ef3c9d068n%40googlegroups.com.

