You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a datatype has two type constructors, one with a value and one without, it may be more efficient to represent the one without as Java null. Consider, for example, the builtin option:
datatype 'a option = NONE | SOME of 'a
We currently represent all datatypes as a Java list. option is as follows:
NONE is Java list with one element: ["NONE"],
SOME 1 is Java list with two elements: ["SOME", 1].
Suppose that we represented it as follows:
NONE is Java null;
SOME 1 is Java Integer(1).
This seems to be more efficient. We have saved a List wrapper in both cases, and saved indirection when handling the datatype.
We cannot use this approach if a datatype has more than one unit constructor. For example builtin datatype order:
datatype order = LESS | EQUAL | GREATER
Maybe instances of unit constructors can be represented as integers (similar to a C++ enum) and constructors with values can continue to be represented as Java lists.
The text was updated successfully, but these errors were encountered:
If a datatype has two type constructors, one with a value and one without, it may be more efficient to represent the one without as Java null. Consider, for example, the builtin
option
:We currently represent all datatypes as a Java list.
option
is as follows:NONE
is Java list with one element:["NONE"]
,SOME 1
is Java list with two elements:["SOME", 1]
.Suppose that we represented it as follows:
NONE
is Javanull
;SOME 1
is JavaInteger(1)
.This seems to be more efficient. We have saved a
List
wrapper in both cases, and saved indirection when handling the datatype.We cannot use this approach if a datatype has more than one unit constructor. For example builtin datatype
order
:Maybe instances of unit constructors can be represented as integers (similar to a C++
enum
) and constructors with values can continue to be represented as Java lists.The text was updated successfully, but these errors were encountered: