Seamless Interoperability with C

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.

By exploiting these features, an ordinary user can make a program such as this sound spectrum analyzer 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.

Last modified:2007/07/06 03:25:09
Keyword(s):
References:[Graphical Animation with Open GL] [Sound Spectrum Analysis] [Features of SML#]