Is there a name for a data structure (read: boolean) that can only be moved from false to true, and not back to false? Imagine something encapsulated like so:
private var _value = false
def value = _value
def turnOnValue() = value = true
And out of curiosity, are there any platforms that support it natively? This seems like something somebody must have come across before…
You’re describing a temporal property of a variable; rather than a data structure as such. The data type is a simple boolean, but it is how it is used that is interesting — as a sort of ‘latch’ in time.
That kind of latch property on a boolean data type would make it an example of a linearly typed boolean. Linear types, and other kinds of uniqueness types are used to enforce temporal properties of variables — e.g. that they can only be used once; or cannot be shared.
They’re useful for enforcing at compile time that an action has happened (e.g. initialization) or having a compile-time proof that an object is not shared. Thus, they’re most common in systems programming, where proofs of low level properties of this are key to correct software design.