[racket-dev] sharing cpointers between namespaces

From: John Clements (clements at brinckerhoff.org)
Date: Thu Oct 28 17:46:30 EDT 2010

I've put together a fix for the inability to share FFI objects between user namespaces... but it has a catch.

Specifically, I moved the define-struct of cpointer into a module by itself, called ffi/unsafe/cvector-def; that way, my tool.rkt file can require this one-line module and attach it to the user's namespace using 'reset-console'.

BUT: the cvector.rkt file wants to use "protect-out" to prevent others from using make-cvector explicitly, and I'm not sure how to do this after moving the structure definition into another file.  Compilation complains:

module: cannot protect imported identifier with re-provide in: make-cvector

... which seems pretty reasonable; there's no way to guarantee that protection when the imported binding could be floating around freely.

I started trying to track down the various instances of make-cvector inside the cvector.rkt module, but then decided it would be easier for a proof-of-concept simply to remove the protection.  

Happily, this solves my problem, but leaves another. Is there some obvious way to recover the protection--after all, I certainly have no need for the user namespaces to call make-cvector--without bloating the startup again?

John

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4669 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20101028/e1090c8b/attachment.p7s>

Posted on the dev mailing list.