Remove .value from Variable?
Currently, one can access a variable's value directly (and instantly) with var.value
, which returns var._value
. This getter returns a value immediately, even if another value is currently being computed for that variable. The value might therefore be breaking an invariant (e.g. if x=1, y=x*2, and we set x=2, at some point during computation both x.value
and y.value
will be 2.
In what scenario would one want to immediately get the current value rather than the value that is being computed?
Also, since the method set
does not update the property ._value
immediately, one gets an old value when asking for the value right after it has been set:
var.set(10)
console.log(var.value) // undefined
Suggestion: Remove .value
from Variable
?