On 12/20/2020 3:34 PM, Dominik Pantůček wrote:
Hello Racketeers,

there were some discussions about structs' introspection on the IRC
lately and one of the questions that arose was how to get field index
for arbitrary struct's arbitrary field.

Not that it is possible... But the general discussion made me think
about why there are no unsafe variants for structs' accessors and mutators.

Have you looked at 'struct-field-info-list' and 'struct-field-index'?

'struct-field-index' works if you know the field name(s), and 'struct-field-info-list' returns fields defined by the struct type - so if your structs types are flat, you can make do with these.

However, 'struct-field-info-list' returns only fields defined by the actual type and does not include fields that were inherited.  What I don't see is any simple way to get at the struct's inheritance hierarchy - it seems that you have to iterate 'struct-type-info' to enumerate the supertypes.

So it is "possible" (for some definition).
George

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/303f6b17-61e2-587c-9636-caca3444ddd4%40comcast.net.

Reply via email to