[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] a couple of questions about foreign functions
From: |
Felix Winkelmann |
Subject: |
Re: [Chicken-users] a couple of questions about foreign functions |
Date: |
Thu, 22 Jan 2004 09:02:50 +0100 |
User-agent: |
Opera7.21/Win32 M2 build 3218 |
Am Wed, 21 Jan 2004 23:52:38 -0800 hat Valentyn Kamyshenko
<address@hidden> geschrieben:
When this function returns, `buf' will point into a dead stack area,
so the data is likely to be corrupted after the return.
I suspected it!.
What makes the following code correct, then (have found it in runtime.c):
[...]
it looks like the vector is created on the stack, and then 'returned' to
the continuation...
Indeed. But the invocation of the continuation (via `C_kontinue') does
*never* return, the data will remain on the stack and be collected
when a certain stack-limit is reached. C-code wrapped with ##core#primitive
invokes it's continuation (and thus the stack is not popped), but code
wrapped with foreign-[callback-]lambda will return normally, in C fashion.
If you mean error-routines that eventually invoke Scheme, then
you should use foreign-callback-lambda*. If you handle the
error in C (for example to display a message and exit), then
I see no problem.
I actually meant smth similar to ##sys#signal-hook (the hope was that
there is C function that do the same).
Not directly. You will have to invoke a Scheme callback for this
(for example defined with `define-external'). But actually it would be
helpful to have a simple C API for raising errors. Thanks for the
suggestion!
cheers,
felix