[racket] Dynamically get all fields of an object?

From: Johann 'Myrkraverk' Oskarsson (myrkraverk at yahoo.com)
Date: Sun Aug 18 13:56:52 EDT 2013

"Johann 'Myrkraverk' Oskarsson" <myrkraverk at yahoo.com> writes:

> Hi all,
> Is it possible to get hold of all fields of an object?  Not just their
> names like with (field-names this) but also (or instead) the values?

Seems like a combination of (field-names ...) and (dynamic-get-field
...) do exactly what I want.

  (let ((fields (field-names this)))
    (for ((field fields))
      (let ((f (dynamic-get-field field this)))
        (when (is-a? f thing%)
          (send f display-thing))))))))

Unfortunately, I ran out of good names and ended up with a symbol f in


Posted on the users mailing list.