[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: good books on scheme?
Richard Cobbe schrieb:
> Lo, on Wednesday, February 7, Immanuel Litzroth did write:
> > Not being a C hacker, but definitely uneducated I wonder if the greatest
> > difference between C function pointers and first-class procedures is not the
> > fact that they cannot be created at runtime because you have neither the
> > compiler nor the symboltable present?
Not so.
Bruno Haible's ffcall library allows the creation of C functions at runtime,
so called trampolines, and extends it to closures as well.
(keeping the data with the functions)
http://clisp.cons.org/~haible/packages-ffcall.html
Ordinary trampolines came with gcc.
ffcall works with gcc and MSVC for sure, others also.
The similar but free libffi package (ffcall is GPL'd) works only with gcc.
I'd try to explain it for dummies at
http://xarch.tu-graz.ac.at/autocad/lisp/ffis.html#libffi
One can extend it to create C++ classes at runtime as well (similar to Java or
better systems, as lisp/scheme/...), but this is hard work and completely
compiler, version and platform specific. Though I would need it terribly for
my work, I wouldn't
do it.
The latest gcc at least mimics the latest msvc conventions, so it's
only one to follow. (The compiler switches for full struct and vtable
compatibility do work now.)
> You *can* do closures in C++, although it's not as convenient as in Scheme:
> class Adder
...
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/