SML# - Language/FFI/Restrictions Diff

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

!! ''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:
# 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.
# Pointers passed from SML# program cannot be saved in C after its return.

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