[plt-scheme] swindle and custom struct
On Sep 6, 2007, at 2:43 PM, YC wrote:
> Hi all -
>
> how can one create a custom struct (i.e. make-struct-type or define-
> struct* from ryanc) but make it work with swindle's object system?
Keep the structure type descriptor (the first value which make-struct-
type returns), and use swindle's struct-type->class on that
descriptor to obtain a class object which describes structs of that
type. For example:
(define-values (struct:my-struct make-my-struct my-struct? my-struct-
get my-struct-set!)
(make-struct-type 'my-struct #f 1 0))
(define <my-struct> (struct-type->class struct:my-struct))
Now you can use <my-struct> anywhere a class object could be used in
Swindle.
Good luck!
Will