[Top][All Lists]

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

Re: [Chicken-users] Chicken C interface

From: Dan Leslie
Subject: Re: [Chicken-users] Chicken C interface
Date: Wed, 05 Jun 2013 08:47:45 -0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

I do this a fair bit in the Allegro egg.

Here's an example:

Basically, use C_alloc to allocate the memory required to host both the List structure and the data it is to contain, then use the C_list macro to patch it all together.


On 6/5/2013 8:10 AM, pluijzer . 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,

Chicken-users mailing list

reply via email to

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