ECMAScript initializes properties ad-hoc per spec, but we never expose partially initialized literals...
This affects things like literals defining get/set pairs and avoiding them being seen as partially initialized.
var _ = 0;
var obj = {
get field() { return _; }
// ...
// No possible code can get a Reference to obj.field , so cannot see that set is not yet applied
// The following line is not possible in this location (accessing `obj` prior to `set`)
other: getRefToObjEarly().field = 1,
// ...
set field(v) { return _ = v; }
}
This invariant makes it seem as if both [[Get]] and [[Set]] are populated at the same time. It greatly simplifies how to think about objects and avoids forcing defensive programming against partially initialized objects.
ECMAScript initializes properties ad-hoc per spec, but we never expose partially initialized literals...
This affects things like literals defining get/set pairs and avoiding them being seen as partially initialized.
This invariant makes it seem as if both [[Get]] and [[Set]] are populated at the same time. It greatly simplifies how to think about objects and avoids forcing defensive programming against partially initialized objects.