[plt-scheme] Recommended style for ncurses ffi?

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Jan 29 14:53:32 EST 2010

On Jan 29, Michael Forster wrote:
> 
> [...]  I've had a look through some of the examples under the ffi
> collection, and I see some function and type names imported
> verbatim.  For example, from magick.ss,
> 
>     (defmagick DestroyMagickWand ...
>     (define _PixelIterator (make-ctype ...
> 
> In xmmsctrl.ss, I see reformatting of names to replace underscores
> with dashes,
> 
>     (defxmms get-playlist-pos ...
>     (defxmms set-playlist-pos ...
> 
> In xsod.ss, I see prefixed names, but that's carried over from the
> foreign api,
> 
>     (defxosd* xosd-set-timeout ...

Right -- I did that intentionally, to show off different ways that it
could be used.  There are cases where you just want to access a single
function from a specific piece of code -- and doing that in a more
schemely way works out.  In other cases you might want to reflect a
whole API, and then the choices are likely to be different -- for
example, keeping the exact same names mean that now you can just
browse the ncurses documentation and look for a particular name.

If you're after the complete interface thing, then I think that the
best choice is to go with the same names as the foreign code, and as
little scheme glue as you can.  The you can have a second wrapping api
that is cmompletely in scheme, and is more scheme friendly.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.