[TYPES] SML# alpha release

Greg Morrisett greg at eecs.harvard.edu
Tue Mar 21 09:08:53 EST 2006


Ian Zimmerman wrote:
> "interoperability" - with what?

A cursory glance at the web site reveals that the compiler
represents scalar values natively (i.e., doesn't tag them as in
SML/NJ or O'Caml) and uses a factored bit-field representation
for records & arrays to support native layouts.  Hence, passing
many data values to/from C (or Java) doesn't require data
conversions.  In that sense, SML# seems to make interoperability
with C/C++ or Java much simpler than other ML compilers.

> "heavily uses type information" - does that mean _runtime_ type
> information?  That would be a significant departure indeed from the
> design of SML ...

Huh?  In what sense does the design of SML dictate that you
should throw away all of the type information you collect
at compile time?

All ML implementations use run-time type information.  They
just represent it and use it differently.  All of them need some
form of type information to support accurate garbage collection.
Most compilers use tags (a la Lisp) to represent
this information at run-time.  Some (e.g., Tolmach's, TIL's,
Minamide's, etc.) have done so-called tag-free collectors which
really just factor the tags out into separate representations.  Only
the original Kit compiler did memory management in a truly tag-free
fashion (but it had bad leaks compared to a tracing collector, so
they've added support for tracing on top of the regions, and hence
tags again.)

Some compilers use the tags to also support polymorphic equality,
while others represent that information "procedurally"
in a style similar to Haskell type class dictionaries.  (Whether
type information is encoded with representation bits, a pointer
to a vtable, or a pointer to a type-specific method doesn't
matter---they're all making it possible to do some form of
run-time type dispatch.)

Some compilers go to an extreme (e.g., TILT) and pass representations
of types to polymorphic functions at run-time so that data
representations, calling conventions, etc. can be specialized.

SML# just goes further in its use of the run-time type representation
information to support things like interoperability (see above),
polymorphic record selection and the other features added to the
language.

-Greg


More information about the Types-list mailing list