[gambit-list] How to pass a procedure to a nonnull-function?
ceving at gmail.com
Thu Nov 3 10:16:15 EDT 2011
2011/11/3 Mikael <mikael.rcv at gmail.com>:
> Yes. The external representation is effectively an int. Btw any closure can
> be passed <-> the external world under the type representation scmobj which
> is effectively an int also, look it up in the manual.
> I'm not clear right now if scmobj:s are persistent to GC iterations though,
> if you/anyone knows please let the ml know.
I think I got it:
;; Local Variables:
;; compile-command: "gsc -exe ffi-hello-3.scm"
(c-define (apply0 proc) (scheme-object) void "apply0" ""
void call_scheme (___SCMOBJ proc)
(c-lambda (scheme-object) void "call_scheme"))
(print "Hello, World!\n"))
(print (procedure? proc) "\n")
Now the C function call_scheme can call any Scheme procedure by using apply0.
With gc persistence you mean that the address of the scheme procedure
might change because of a mark and compact gc? That would be a problem
and will break the above code.
The Gambit documentation distinguishes movable and nonmovable objects in:
But I can not find any description how to make an object nonmovable.
Does anybody know how to make a closure nonmovable?
More information about the Gambit-list