> On Aug 3, 2020, at 11:48, Hendrik Boom <hend...@topoi.pooq.com> wrote: > > Still, it would be nice to find out how to get this information more > directly instead of relying on functions that do much more than > what I was asking for.
In general, there aren’t any. The ability of struct->vector to extract a symbolic name for any value really is specific to struct->vector (and it’s only really useful for debugging, for the reason Ryan points out). If you only care about bona fide structs, not primitive values like strings and ports, you can do a little better using struct-info: (define (type-name v) (match/values (struct-info v) [(#f _) #f] [((app struct-type-info name _ _ _ _ _ _ _) _) name])) (struct point (x y) #:transparent) (type-name (point 1 2)) ; => 'point But this doesn’t work for non-transparent structs unless you own a sufficiently powerful inspector: (let () (struct point (x y)) (type-name (point 1 2))) ; => #f (let () (struct point (x y) #:inspector (make-inspector)) (type-name (point 1 2))) ; => 'point But again, this just gets you a symbolic name, which is subject to the same issue Ryan points out. The value you get back from struct-info is truly unique to that particular type, so it’s a more useful value than the symbolic name. But again, it’s not clear to me why you’d want to do this (except for debugging/instrumentation), since you still can’t possibly do anything useful with a value of a truly unknown type. On the other hand, if it *is* for debugging, then meddling with the inspector is a valid thing to do (and is in fact one of the main reasons inspectors exist). You can change current-inspector to a weaker inspector during the instantiation of the modules you want to debug, and then you can use struct-info to get information about any values of the struct types they create. Alexis -- 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/5CAB018A-6F47-4FBA-A249-6A7472D8A896%40gmail.com.