chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Chicken C interface


From: Kristian Lein-Mathisen
Subject: Re: [Chicken-users] Chicken C interface
Date: Thu, 6 Jun 2013 01:20:39 +0200


I just though I'd mention srfi-4 as well, which are much easier to interface with from C. If all your elements are integers, for example, you might want to check out u32vector. Srfi-4 vectors use plain C float/int arrays and are possible as argument-types from foreign-lambda and friends.

K.


On Wed, Jun 5, 2013 at 5:10 PM, pluijzer . <address@hidden> wrote:
Hello everybody,

I was planning to use Chicken Scheme in a fashion more similar to Guile and Lua. i.e. passing Scheme Data Objects from Chicken to C and back using the C interface.

I am a little confused though as how to have a C function return a Scheme List that is seen by the garbage collector.

For example, is the code below correct, will the list be seen by the garbage collector? And if not, is there correct way to do this.

#>
C_word give_12()
{
  C_word *mem  = C_alloc(C_SIZEOF_LIST(2));
  C_word  list = C_list(&mem, 2, C_fix(1), C_fix(2));
  return list;
}
<#
(print ((foreign-lambda scheme-object "give_12")))

Also there doesn't seem to be a C_listp predicate. Is this a concious omission?

thank you in advance,
Richard

_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users



reply via email to

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