ML-like Cell[T] type

Constantine Plotnikov


At one of stages of the project it were considered to implement mutable state as cell[T] type. This could give unification of MutableBox type, MutableArrayType, and variable types. So mutable array were Array[Cell[T]] and T.BoxedMutable would became Cell[T].Boxed.

I wanted cell to be value type rather then object type like it was done in ML for performance reasons. It were reason for failure. I have considered changing it to object type, but dropped this idea as it would harm performance and require extensive optimizations.

When I have tried to create class libraries with such design, I noticed that I need to support too many special cases in compiler and in templates for this type. As it needs to be converted as Ref[T] on out values and T on input values.

As unification has not worked well, I droped this design, and explicitly introduced variables, T.BoxedMutable and MutableArray[T] types.

Ref[T] generic typed reference type was dropped too. As it were not generic enough. Instead were added lvalue operations that were used if result were assigned to it. This is very similar to scheme design for generic (set! a b) macro. out and inout paramenters modifier were made explicit.