A variable is a container for a value of a particular type.
A variable is a container for a value of a particular type.
When initialized, the variable is known to be holding a value of that type.
We can read a value from it when we refer to it by name.
But if it’s an isolated type, the isolated root is still held by the variable, so the value we read is only an alias, heavily restricting what we are allowed to do with it.
iso'aliased
(
x)
To extract an isolated value from a variable, we must consume it.
This leaves the variable holding nothing, so reading from it is no longer allowed.
iso
(
--x)
To fill an empty variable, we can assign a new value to it.
The result value that comes out of such an expression is the alias of the new value.
iso'aliased
(
x =
Thing.new
)
This is also true for a variable that is already holding a value.
The alias of the new value is returned and the old value is lost.
iso'aliased
(
x =
Thing.new
)
To capture the old value we can use displacing assignment.
The fully isolated old value is returned, because the new value has taken its place in the variable.*
iso
(
x <<=
Thing.new
)