Restrictions in 0.20 Release

char and short in struct

SML# does not support packed data in struct. For example, if the platform generates a packed representation for

struct S {char x; char y;};
int f(struct S* s);

then the following usage will result in undefined state.

val f = DynamicLink.dlsym(lib, "f") : _import (char * char) -> int;

Pointer and GC

Under the current memory management technology, it is impossible to handle pointers that point to a middle of a heap block. This implies that a pointer generated in C program cannot be safely imported as an SML# pointer. Also, current SML# does not implement cross language GC.

As a result, the current SML# system had to impose the following restrictions:

  1. a foreign pointer cannot be imported as an SML# pointer; it no problem to import a C pointer as an abstract atomic value. 'a ptr type in SML# is an example.
  2. Pointers passed from SML# program cannot be saved in C after its return.

Some FFI utility function are provided to deal with these problems. In future release, we plant to provide more systematic support for cross language GC.

Last modified:2007/03/29 13:33:59
Keyword(s):
References:[Foreign Function Binding]