SML# - FeatureInteroperability Diff

  • Added parts are displayed like this.
  • Deleted parts are displayed like this.

One of the design goals of SML# is to achieve high degree of
interoperability with C and other existing languages.

At this moment, full-fledged ML languages (i.e. those that
provide the usual benefits of ''interactive programming'',
''polymorphism'', and ''higher-order functions'') do not necessarily
have interoperability with C and other existing languages in their
represenation of basic data structures.
In representative implementations, integers are tagged and floating
point numbers are always heap allocated. Due to these "features", ML
programs cannot directly link with C libraries.

SML# solves this problem without resorting to whole program analysis
or runtime type inspection. In SML#, integers and floating point
numbers have their natural representations, and they can be freely
mixed with other data structures such as records and arrays.
Moreover, the heap architecture of SML# does not depend on its type
system nor the compiler.
These features make SML# highly interoperable. In SML#, the programmer
can open a dynamically linked library, bind a function in it and use
it as an ordinary function.
The following simple examples introduce this feaure.

* [[FFI Intro : using the Mersenne Twister random number generator|Resources/ProgrammingExamples/MT]]
* [[C functions with callbacks|Resources/ProgrammingExamples/CallBack]]
* [[C functions with structs|Resources/ProgrammingExamples/Struct]]
* [[Polymorphic C functions|Resources/ProgrammingExamples/PolyC]]

By exploiting these features, an ordinary user can make a program such
as this [[sound spectrum analyzer|Resources/ProgrammingExamples/Spectrum]]
without any special stub or data conversion library.

In its complete form, SML# plan to support
* static and dynamic linking to C functions with true separate compilation,
* type-safe interface to Java through record polymorphism, and
* record and set based interface to databases.
In the current 0.20 release, only dynamic linking to C functions is supported.