[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] idiom question
From: |
Peter Keller |
Subject: |
Re: [Chicken-users] idiom question |
Date: |
Sun, 6 Oct 2002 01:19:59 -0500 |
User-agent: |
Mutt/1.2i |
On Thu, Oct 03, 2002 at 06:37:52PM -0500, Peter Keller wrote:
> Hello,
>
> I have a question concerning an idiom I want to do in the C FFI.
Ok, this is the best I've found so far:
(require 'srfi-4)
(define foo (s32vector 42))
(declare
(foreign-declare #<<EOF
int foobar(int *p)
{
int old = *p;
*p += 1;
return(old);
}
EOF
))
(define foobar
(foreign-lambda int "foobar" s32vector))
(let ((f (foobar foo)))
(print f " " (s32vector-ref foo 0)))
Can anyone do better? Idealy, I want to take out the explicit s32vector if I
can. I just want this to work:
(define foo 42)
(let ((f (foobar foo)))
(print f " " foo))
and get :
42 43
as a result. I'm happy to add code to do typechecking and stuff, But I
really just want a super clean interface to foobar().
Thanks.
-pete