env.[[HomeObject]] is always equal to env.[[FunctionObject]].[[HomeObject]], so it's redundant.
(I wonder if this is a leftover artifact from an early draft in which [[HomeObject]] was an extra implicit parameter passed to every function, independent of [[FunctionObject]], more like [[ThisValue]].)
I submitted this issue because the presence of [[HomeObject]] in Table 15 confused a person in the real world this morning. :)
I agree there is no observable difference between these two specification alternative.
But, there is a subtle difference of intent that may be communicated by the original formulation.
Environments represent a set of binding and once established those bindings are generally resolved without reference to the function/block that instantiated the binding. [[HomeObject]] was conceptualize as a special binding and as such it was explicitly included in the environment. Just like each attempt to resolve a binding doesn't specify an indirection through [[FunctionObject]].[[Environment]] accessing the home object bind didn't indirect through [[FunctionObject]].[[HomeObject]]
What's the value of avoiding the indirection through [[FunctionObject]]?
But, there is a subtle difference of intent that may be communicated by the original formulation.
Can we just add a note that says this? Or [[HomeObject]] could be specified as a special binding, if it really works that way. There's nothing wrong with the point being made. But the spec as it stands is confusing.
The editor group is in favor of @jorendorff's original suggestion of removing the indirection. Wanna take a stab at a PR @jorendorff?
Do you mean removing env.[[HomeObject]]? If so, sure, I can take a second to do that.
Is this not different when the FunctionObject is an arrow function?
const object = Object.setPrototypeOf({
method() {
return (() => super.homeObjectPrototypeProperty)();
}
}, { homeObjectPrototypeProperty: 7 });
object.method(); // 7
(I鈥檓 guessing not, given the prior discussion, but I鈥檇 have previously assumed that was the reason they were distinct, and I鈥檓 having trouble tracing how the right [[HomeObject]] ends up used here.)
It's always an alias, see https://tc39.es/ecma262/#sec-newfunctionenvironment, the only place where [[HomeObject]] is ever set on an environment.
Thanks @devsnek. I鈥檓 still having trouble figuring out how/where the super reference above gets resolved, but can see that you鈥檙e correct.
@bathos the super env is resolved by performing GetThisEnvronment()
OK, filed a PR.
The table of function Environment Record methods has gotten out of date, so I updated it.
But, I think that table has outlived its usefulness, and it would be more helpful to distribute the comments in the Purpose column to the sections defining those methods. Separate issue, though.
Most helpful comment
It's always an alias, see https://tc39.es/ecma262/#sec-newfunctionenvironment, the only place where [[HomeObject]] is ever set on an environment.