From: Matthew Flatt <mflatt@cs.utah.edu>
To: plt-scheme@fast.cs.utah.edu
Date: Mon, 25 Jun 2001 10:48:46 -0600 (MDT)
Subject: 199.16

The v200-tagged code in CVS for MzScheme and MrEd is now version 199.16.

The main change is that mzc supports a subset of the Gambit-C
foreign-function interface. For example:

  (define fmod (c-lambda (double double) double "fmod"))

creates a Scheme function that calls the standard fmod() C function.
The body part of the function can either be a C function name, as
above, or it can be C code that accesses ___arg1, etc. and sets
___result. (The three underscores underscore the Gambit heritage. :)

  (define machine-string->float
    (c-lambda (char-string) float
       ;; assume that the string is 4 bytes
       "___result = *(float *)___arg1;"))

The `c-lambda’ form can be used anywhere. There’s also a `c-declare’
form (used for #includes, etc.) that must appear at the top-level or in
a module top-level.

When interpreted directly or compiled to byte code, `c-lambda’ produces
a function that always raises `exn:user’, and `c-declare’ raises
`exn:user’. [Yes, it would be nice if those were syntax errors.]

The `c-lambda’ and `c-declare’ forms are defined by a new "cffi.ss"
module in the "compiler" collection. When compiling a file, mzc
automatically imports the cffi module into the top-level namespace.

See the mzc manual (now ported to v200) for more information, and see
plt/collects/mzscheme/examples for additional small examples.

[This subset of the Gambit-C FFI seems useful (compare the `fmod’ line
above to the 25-line plain C example), and it was trivial to implement
for mzc. I don’t know why I never thought of this before, but it might
be because I kept looking for FFIs that would work well with the
interpreter (without mzc).]

Other changes:

 * Fixed `subprocess’ for Windows [really, this time... hopefully].

 * The self object is passed to `demand-callback’ procedures.

Inside MzScheme:

 * New scheme_c_pointer_type built-in type --- with scheme_make_cptr(),
   SCHEME_CPTRP(), SCHEMECPTR_VAL(), and SCHEME_CPTR_TYPE() --- that
   makes simple extensions easier to write. (Used by `c-lambda’.)

 * schvers.h now defines MZSCHEME_VERSION, MZSCHEME_VERSION_MAJOR, and
   MZSCHEME_VERSION_MINOR (instead of VERSION), and [e]scheme.h
   includes schvers.h.

 * The "Inside MzScheme" manual is up-to-date.

The MzScheme, MzLib, MrEd, mzc, and Inside MzScheme manuals have been
updated. Temporary PDF versions of the manuals are available at
  http://www.cs.utah.edu/~mflatt/tmp/

Matthew