Is it possible to get all the fields of an object in a racket at the same time?
I would like to basically convert the object to a hash table with field names as keys and field values ββas values.
I found a function (obj field names), but then I do not know how to use returned field names to get values ββfrom obj. The get-field function can be used to get the value of a field, but I don't know how to use it with a value:
> (define x% (class object% (init-field xy) (super-new))) > (define obj (make-object x% 1 2)) > (get-field x obj) 1 > (field-names obj) '(yx) > (define field-name (second (field-names obj))) > field-name 'x > (get-field field-name obj) get-field: given object does not have the requested field field name: field-name object: (object:x% ...) errortrace...: context...: /usr/lib/racket/collects/racket/private/class-internal.rkt:4906:0: obj-error29 /usr/lib/racket/collects/racket/private/misc.rkt:87:7
source share