[plt-scheme] (lib "foreign.ss") and vararg C functions

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Oct 7 18:25:50 EDT 2005

On Oct  7, Eli Barzilay wrote:
> On Oct  7, Matthias Felleisen wrote:
> > So one could create an "overloaded" printf library that picks up
> > from C?
> Yes -- guessing the type according to the Scheme value.  The simple
> approach would be to look at the input types, construct a foreign
> interface and immediately apply it.  But it'll be better to cache
> the resulting interfaces.

Added to svn:
with a usage example in

Also, C's printf is bad for your health, unless you parse the format
string and verify that it matches the types -- otherwise you can
always print a random number where a string is expected.  So this code
demonstrates how to provide `hidden' things, like foreign.ss's
bindings that are available only after `(unsafe!)'.

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

Posted on the users mailing list.