Open DavePearce opened 4 years ago
As an interesting point, the following must have linear type:
type l_rec is { linear int field }
Linearity of l_rec
is implicit because it contains a field which is itself linear. An interesting question then becomes about this:
type Box<T> is { T field }
At this point, we might want to be able to write Box<linear int>
or similar to denote a proper linear item.
An interesting question would be to add linear types to Whiley. This could take the form of a
linear
modifier which, in fact, is very similar to the existingfinal
modifier. The following illustrates some examples:The above doesn't compile because the second assignment is not permitted (same as for
final
).The above does compile (same as for
final
).The above does not compile because
y
is notlinear
(differs fromfinal
). Likewise, as follows:Again, the above does not compile because
a
is notlinear
.See: The Design and Formalization of Mezzo, a Permission-Based Programming Language, TOPLAS'16.