[plt-scheme] define-cstruct, mutual dependency

From: Robert Nikander (nikander at nc.rr.com)
Date: Wed Oct 24 08:55:32 EDT 2007

On Oct 24, 2007, at 1:48 AM, Jon Rafkind wrote:
> After a lot of futzing around I got this to work
> (require (lib "foreign.ss"))(unsafe!)
> (define-cstruct _A
>         ((x _int)
>          (b (_cpointer #f #f (lambda (c) c)
>                    (lambda (c) (cpointer-push-tag! c B-tag) c)))))
> (define-cstruct (_B _A)
>         ((q _int)))

Aha!  Thank you, that is working great.

For anyone else wanting to copy this... I added (cpointer-push-tag! c  
A-tag) so the `b' field has both tags.  And if `b' were settable, I  
guess you would check for (cpointer-has-tag? c B-tag) in the first  


Posted on the users mailing list.