Re:Public and private class fields
by BillinghamJ on Thursday December 13, 2018 @06:24PM
(#18677088)
Normally it could be effectively optimised away and just treated as an extra argument.
But it's also required by the spec that `foo().method !== foo().method` when returning new functions from a closure in `foo`, so the function has to be wrapped and a new structure allocated each time to differentiate.
Thanks. I suspect the internals of “===“ in this case could look for the presence of a closure data pointer on a Function or some such hack.
Anyway, I’d probably use an actual prototype on something (with “methods” and) hundreds of instances, but otherwise, I’m not too worried about just using closures and object literals.
There are obviously some stack or other data frames that have to be captured somehow, but the code itself should in principle be something the VM makes a single copy of with references to in each object using it as a property. (Internally within a Function type reference, separate trackers for the instructions vs the bound data)