Escalier introduces the idea of mutable references. By default an immutable reference of type T will be equivalent to type Readonly<T>.
An object type T can contain a mix of readonly and mutable fields. A binding mut x: T allows x to mutate all fields except readonly fields and call all methods on T including those with mut self: Self as the receiver. In TS this would mean that Readonly<Set<T>> == ReadonlySet<T>, Readonly<Map<T>> == ReadonlyMap<T>, etc. which currently isn't the case.
Readonly<T> makes all properties readonly and removes all methods with mut self: Self as the receiver. This means that T is assignable to Readonly<T> (aka T is a subtype of Readonly<T>).
Given the binding x: T, i.e. x is not mutable, typeof x should return Readonly<T>.
Escalier introduces the idea of mutable references. By default an immutable reference of type
T
will be equivalent to typeReadonly<T>
.An object type
T
can contain a mix of readonly and mutable fields. A bindingmut x: T
allowsx
to mutate all fields except readonly fields and call all methods onT
including those withmut self: Self
as the receiver. In TS this would mean thatReadonly<Set<T>> == ReadonlySet<T>
,Readonly<Map<T>> == ReadonlyMap<T>
, etc. which currently isn't the case.Readonly<T>
makes all properties readonly and removes all methods withmut self: Self
as the receiver. This means thatT
is assignable toReadonly<T>
(akaT
is a subtype ofReadonly<T>
).Given the binding
x: T
, i.e.x
is not mutable,typeof x
should returnReadonly<T>
.