[erlang-questions] idea: Erlang FFI: new draft EEP and patches
Alceste Scalas
alceste@REDACTED
Thu Nov 15 15:15:20 CET 2007
Hello,
after some developers' feedback (special thanks to Serge Aleynikov!),
I've updated the Erlang FFI draft EEP and patches. Everything is
available at the usual place:
http://muvara.org/crs4/erlang/ffi
The previous Erlang FFI report is available in [1]. Here's a quick list
of changes in the new release:
1. EEP: some notes about type contracts, libffi dependency, vararg
functions;
2. patches: moved the FFI high-level API in a brand-new ffi library
(it was inside the kernel library before). It should be a
cleaner approach, and allows the Erlang build procedure to warn
if the FFI support could not be enabled for some reason.
I think that this version of the EEP can replace the old EEP 7 that is
currently available on erlang.org [2].
As usual, your feedback is welcome --- and encouraged!
There are a few aspects that should be improved:
1. the high-level, type-tagged FFI API may overlap in functionality
with type contracts (see "Notes on type-tagged values" [3]);
2. floating-point checking functions should be improved, e.g. to
return FLT_EPSILON for the current platform (some changes to
ffi.erl should be enough, without touching the emulator C
sources). This is partially related to the previous point;
3. when the emulator is compiled without FFI support, the FFI BIFs
should throw a more descriptive error (they now cause a
not-very-helpful 'badarg'...);
4. the patches are untested on bigendian platforms (I expect them
to require several fixes --- beta testers needed!)
"1" and "2" can be solved in different ways, depending on type contracts
capabilities and Erlang developers' feedback. "3" may require the
introduction of a new BIF error, so Erlang core developers' opinion
would be more than welcome. "4" just needs someone with a bigendian
machine at hand...
I think that including the FFI as an experimental feature in OTP R12B
could help solving all these issues. On bigendian machines, it could be
disabled by default.
The current reference implementation is based on OTP R11B-5 --- but if
there is some possibility to include the FFI in R12B, then I could adapt
the patches to the R12B snapshots (it *seems* to be quite easy, but the
snapshots are a moving target...).
Regards,
alceste
References:
[1] Previous report about the FFI extension for Erlang/OTP:
http://erlang.org/pipermail/erlang-questions/2007-September/029586.html
[2] Current version of the EEP 7 (Foreign Function Interface):
http://www.erlang.org/svn/projects/eeps/trunk/eep-0007.txt?revision=19&view=markup
[3] FFI EEP: Notes on type-tagged values
http://muvara.org/crs4/erlang/ffi/eep-ffi.html#notes-on-type-tagged-values
--
Alceste Scalas <alceste@REDACTED>
CRS4 - http://www.crs4.it/
More information about the erlang-questions
mailing list