@pnwamk Thanks for the pointers. I’d already built myself a datatype macro whose surface syntax looks pretty much exactly like your define-datatype; I’m interested to check out your type-case. Giving the type explicitly isn’t really a problem, but I’m curious if it would be possible to determine the type of the first form, since Typed Racket should know it (although maybe at the wrong time?).
Yup, that’s exactly what I’m talking about. :slightly_smiling_face:
@mflatt I want to double check with you as the docs aren’t 100% clear. When I allocate a cstruct using its make-<id> allocator, the result is still tracked by the GC, yes?
yes
Okay. So it is then not safe to hand a pointer to it to a C function that then takes ownership of it?
Correct.
In which case it looks like the only way to make one is to: A. call malloc explicitly in raw mode, and manually set the fields.
Okay cool, thanks you.
You can supply an alternative malloc
mode with #:malloc-mode
if you always want to allocate as, say, 'raw
Otherwise, yes, use malloc
, etc..
okay cool, that makes sense.
Thank you
@mflatt Also, I presume list->cblock allocates the block with atomic?
That one does seem inadequately documented. I see that the implementation uses malloc
with the given type, so that’s not always atomic.
Interesting, okay.
Thank you
@mflatt Its more that I wanted to hand it off to a c function.
But it looks like I’ll have to keep a copy around on the Racket side until I know its safe to free it.