On 2013-06-05 23:36, Felix wrote:
From: Dan Leslie d...@ironoxide.ca
[...]
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.
Note that this code is not correct: C_alloc
On Thu, Jun 6, 2013 at 11:34 AM, Thomas Chust ch...@web.de wrote:
On 2013-06-05 23:36, Felix wrote:
From: Dan Leslie d...@ironoxide.ca
[...]
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
On 2013-06-06 11:46, Kristian Lein-Mathisen wrote:
[...]
From what I understand, this is exactly what foreign-primitive does:
wraps C_return in a CPS, keeping the stack-allocation alive.
[...]
Hello,
well, kind of.
Since compiled CHICKEN code is fully CPS transformed you don't wrap
I did not read your question properly, sorry! Thanks for the clarification,
I didn't know foreign-lambda were the one that had to do the
CPS-conversion. Does that mean there is a small performance overhead when
using foreign-lambda as opposed to just foreign-primitive?
K.
On Thu, Jun 6, 2013 at
From: Thomas Chust ch...@web.de
Subject: Re: [Chicken-users] Chicken C interface
Date: Thu, 06 Jun 2013 11:34:40 +0200
On 2013-06-05 23:36, Felix wrote:
From: Dan Leslie d...@ironoxide.ca
[...]
Basically, use C_alloc to allocate the memory required to host both
the List structure
On 2013-06-06 12:13, Kristian Lein-Mathisen wrote:
[...]
I didn't know foreign-lambda were the one that had to do
the CPS-conversion. Does that mean there is a small performance overhead
when using foreign-lambda as opposed to just foreign-primitive?
[...]
Hello,
the overhead is roughly one
On 2013-06-06 12:19, Felix wrote:
From: Thomas Chust ch...@web.de
[...]
when I first saw that code I thought that this must be incorrect, too.
Then I checked the CHICKEN documentation for foreign-safe-lambda and read:
This is similar to foreign-lambda, but also allows the called
From: Thomas Chust ch...@web.de
Subject: Re: [Chicken-users] Chicken C interface
Date: Thu, 06 Jun 2013 12:29:01 +0200
On 2013-06-06 12:19, Felix wrote:
From: Thomas Chust ch...@web.de
[...]
when I first saw that code I thought that this must be incorrect, too.
Then I checked the CHICKEN
On 2013-06-06 12:34, Felix wrote:
From: Thomas Chust ch...@web.de
[...]
So what about allocating locally and not returning an object but passing
it to a Scheme callback from inside a foreign-safe-lambda? Is that ok or
can it happen that the callback stores this object away but never copies
On 6/6/2013 2:59 AM, Thomas Chust wrote:
Therefore foreign-primitive can do allocation in the nursery, but
foreign-lambda can't. However, foreign-lambda could still allocate
directly in the second generation heap or transfer nursery-allocated
values directly into the heap upon return before
From: Dan Leslie d...@ironoxide.ca
Subject: Re: [Chicken-users] Chicken C interface
Date: Thu, 06 Jun 2013 09:54:41 -0700
On 6/6/2013 2:59 AM, Thomas Chust wrote:
Therefore foreign-primitive can do allocation in the nursery, but
foreign-lambda can't. However, foreign-lambda could still
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
I do this a fair bit in the Allegro egg.
Here's an example:
https://github.com/dleslie/allegro-egg/blob/985ca2ceef0f5b4028af3f97729f13cba2976fe5/color.scm
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
On Wed, Jun 05, 2013 at 08:47:45AM -0700, Dan Leslie wrote:
I do this a fair bit in the Allegro egg.
Here's an example:
https://github.com/dleslie/allegro-egg/blob/985ca2ceef0f5b4028af3f97729f13cba2976fe5/color.scm
Basically, use C_alloc to allocate the memory required to host both the
On 2013-06-05 19:50, Peter Bex wrote:
[...]
There is no C_listp predicate because you can't directly check an
object for being a list; you must check whether it's
C_SCHEME_END_OF_LIST (then it is a list). Otherwise, if it's a pair
you take its cdr and loop. If it's something else, it's not
On Wed, Jun 05, 2013 at 07:57:49PM +0200, Thomas Chust wrote:
Hello,
but it's trivial to detect cyclic lists during the traversal using
either a set of seen elements or just two iteration pointers travelling
at different speeds.
In C that's rather painful. Note that the OP was asking
On 2013-06-05 20:11, Peter Bex wrote:
On Wed, Jun 05, 2013 at 07:57:49PM +0200, Thomas Chust wrote:
but it's trivial to detect cyclic lists during the traversal using
either a set of seen elements or just two iteration pointers travelling
at different speeds.
In C that's rather painful.
this should work for basic list test
(import foreign)
#
C_word C_listp(C_word p)
{
if (p == C_SCHEME_END_OF_LIST)
{
return C_SCHEME_TRUE;
}
// check for non-immidiate object and pair?
if (!C_immediatep(p) C_pairp(p) ==
C_SCHEME_TRUE)
{
return
C_listp(C_u_i_cdr(p));
}
return
On Wed, Jun 05, 2013 at 08:19:15PM +0200, Thomas Chust wrote:
On 2013-06-05 20:11, Peter Bex wrote:
On Wed, Jun 05, 2013 at 07:57:49PM +0200, Thomas Chust wrote:
but it's trivial to detect cyclic lists during the traversal using
either a set of seen elements or just two iteration pointers
From: Dan Leslie d...@ironoxide.ca
Subject: Re: [Chicken-users] Chicken C interface
Date: Wed, 05 Jun 2013 08:47:45 -0700
I do this a fair bit in the Allegro egg.
Here's an example:
https://github.com/dleslie/allegro-egg/blob/985ca2ceef0f5b4028af3f97729f13cba2976fe5/color.scm
Basically
From: pluijzer . pluij...@gmail.com
Subject: [Chicken-users] Chicken C interface
Date: Wed, 5 Jun 2013 17:10:41 +0200
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
Oh dear!
Well, it works and I haven't had problems. What's the correct way to go
about this?
-Dan
On 6/5/2013 2:36 PM, Felix wrote:
From: Dan Leslie d...@ironoxide.ca
Subject: Re: [Chicken-users] Chicken C interface
Date: Wed, 05 Jun 2013 08:47:45 -0700
I do this a fair bit in the Allegro
Thanks, I'll get on updating my broken eggs soon.
obvious humpty dumpty joke notwithstanding
-Dan
On 6/5/2013 2:39 PM, Felix wrote:
From: pluijzer . pluij...@gmail.com
Subject: [Chicken-users] Chicken C interface
Date: Wed, 5 Jun 2013 17:10:41 +0200
Hello everybody,
I was planning to use
I just though I'd mention srfi-4 http://api.call-cc.org/doc/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
Subject: Re: [Chicken-users] Chicken C interface
Date: Wed, 05 Jun 2013 08:47:45 -0700
I do this a fair bit in the Allegro egg.
Here's an example:
https://github.com/dleslie/**allegro-egg/blob/**
985ca2ceef0f5b4028af3f97729f13**cba2976fe5/color.scmhttps://github.com/dleslie/allegro-egg/blob
25 matches
Mail list logo