[Top][All Lists]

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

Re: [Chicken-users] Chicken C interface

From: Peter Bex
Subject: Re: [Chicken-users] Chicken C interface
Date: Wed, 5 Jun 2013 19:50:38 +0200
User-agent: Mutt/

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:
> 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.
> >Also there doesn't seem to be a C_listp predicate. Is this a concious 
> >omission?

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 a list.

Because this is a potentially heavy operation (and cyclic lists may
even cause an endless loop), I guess it's been decided not to provide
a predicate procedure for this, because it's too tricky to get right,
and usually you want to avoid traversing the list twice anyway, so the
operation itself is often embedded in the CDRing logic.


reply via email to

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