chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] New "easy" FFI


From: Miles Egan
Subject: Re: [Chicken-users] New "easy" FFI
Date: Mon, 22 Sep 2003 15:24:05 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030903 Thunderbird/0.2

felix wrote:

On Mon, 22 Sep 2003 14:42:30 -0700, Miles Egan <address@hidden> wrote:

felix wrote:

Hiya!

Chicken got a new FFI interface (informally called the "easy" FFI).
It parses a subset of C and generates procedure and variable bindings
from declarations, like this:

#>! #include <math.h>

#define my_pi 3.14

int var = 99;
extern double sin(double);
<#

(print (sin my_pi))
(print (var))
(var 123)
(print (var)) ; now 123

The parser does basic macro substitution, handles simple macros,
enums, typedefs, variable declarations and function prototypes.
Most preprocessor commands are implemented.


Pretty cool.

Why did you decide to treat C variables (var in the above) as scheme functions instead of scheme variables?


If you treat them as normal variables, then they're only available in
the current compilation unit - it's currently not possible to
"export" foreign variable bindings. But perhaps I should make
this optional? We could add optional processing instructions
after the "#>[!?]" to fine-tune the parsing process.
Any suggestions welcome!

I suppose I'd prefer to have variables treated consistently. I'd rather see them exposed as functions in all cases even though it seems a little strange than to have them exposed as functions in some cases and variables in others.

miles





reply via email to

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