[racket] Dynamically get all fields of an object?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Aug 19 09:50:57 EDT 2013

The 'f' isn't a field but a field-s-value. 

And (define field-s-value (dynamic-get-field field this)) will avoid some rightward drift. 

-- Matthias

On Aug 18, 2013, at 12:56 PM, Johann 'Myrkraverk' Oskarsson wrote:

> "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
> there.
> Johann
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Posted on the users mailing list.