Description
openedon Dec 17, 2018
Unlike typical arrays, the array passed as the first argument to a tag function is not Extensible. Please read this:
https://stackoverflow.com/questions/53808065/array-argument-not-extensible-in-tag-function
Because it has never been extensible, making it extensible now, wouldn't create any backward compatibility issues.
Why make it extensible?
The fastest possible way to access processed-output, based on this array, is to add a property to the array itself that references the object that caches that processing.
Just like the array itself doesn't change on multiple tag functions calls, the processing done to that array also often does not change. Therefore, that processed output needs to be cached too. Right now, because this array is not extensible, you have to use a slower mechanism to do this caching: a Map object. Map objects are fast, but they are not faster than adding a property to the array and caching it there:
let cacheObject = someMapObject.get(aryOfStaticParts); // Is not faster than:
let cacheObject = aryOfStaticParts.cacheObject; // Faster, but can't do it (not extensible)
Making this array extensible shouldn't break current functionality. This specified prevention of extensibility is not essential to facilitating existing functionality.
In ecmascript, arrays were made extensible for a good reasons: flexibility and speed.
Some people frown upon adding properties to an array. But there are circumstances where doing so is the most performant way to accomplish a task. The code above is a perfect example of this.
The original designers of this language understood the flexibility and speed gained by making arrays extensible. I'd like new specifications to follow this precedent. I propose we change the specification to make this array extensible like every other default array in the language.
Activity