[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] problem with callbacks

From: Felix Winkelmann
Subject: Re: [Chicken-users] problem with callbacks
Date: Fri, 23 Jan 2004 08:18:44 +0100
User-agent: Opera7.21/Win32 M2 build 3218

Am Thu, 22 Jan 2004 09:34:44 -0500 (EST) hat Daniel B. Faken <address@hidden> geschrieben:

Hello all,

  My 'foreign-callback-wrapper' doesn't seem to be capturing the local
environment - is this correct?

That is correct. Both `foreign-callback-wrapper' and `define-external'
(which expands into the former) do not capture the lexical environment.
The problem is that C invokes the callback directly via it's function
address, to pass the lexical environment and extra argument would have
to be passed. A workaround is to call your target procedure indirectly:

(define bar #f)

(let ([foo 99])
  (set! bar (lambda () (print foo))) )

(define-external (cb) void
  (bar) )

__callback void ccb() { extern void cb(); cb(); }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]