[plt-scheme] How get name of structure
Or better allow f to work for structs controlled by the current inspector too:
(define-struct structure1 (f1) (make-inspector))
(define-struct structure2 (f1 f2))
(define x (make-structure1 1))
(define y (make-structure2 'a 'b))
(define (f x)
(parameterize ((print-struct #f))
(printf "Name of structure ~a~n"
(regexp-replace* "^.*<struct:|>$" (format "~s" x) ""))))
(f x) ; displays Name of structure structure1
(f y) ; displays Name of structure structure2
Jos Koot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070411/ff8655b2/attachment.html>