In ATS, there are two sorts ‘type’ and ‘t@ype’ (or ‘t0ype’) where the
former is for boxed types
and the latter for (potentially) unboxed types. A boxed type is really just
a special case of unboxed type.
Internally, any type T can be treated as a boxed type if sizeof(T) =
sizeof(ptr) (where ptr is the type for
pointers).
Every datatype in ATS is a boxed type; every type formed using the syntax
’{…} is
a boxed (tuple/record) type; etc. Primitive types like ‘char’, ‘int’,
‘double’ are not boxed types.
The type ‘string’ (for strings) is not considered a boxed type by default.
Also, any function types
(that is, types for functions) are not considered a boxed type by default.
However, there are boxed
versions for these types. For instance, boxed(string) is the boxed version
of ‘string’, which is internally
the same as ‘string’; boxed((int, int) -> bool) is the boxed version of
’(int, int) -> bool’; etc.
val A = "A"
val A1 = box(A) // A1: boxed(string)
val A2 = unbox(A) // A2: string
In the above code, A, A1, and A2 are all the same value internally.
In practice, the need for types like boxed(string) is very are; it happens
most likely in a situation where
polymorphic functions (rather than function templates) are called.