On 7/19/2013 9:52 AM, Allen Wirfs-Brock wrote:
Even if you could, I highly doubt that proxy performance will ever be
up for the task, at least not for an implementation cost that isn't
much higher than the special casing.
Like I said, I don't see how this is a performance issue for Symbols exotic
objects because the MOP operations are never important for them.
Indeed, a largely self-hosted implementation of Symbol could look like:
const UNDEFINED = () => {};
const TRUE = () => true;
const FALSE = () => false;
const NULL = () => null;
const ARRAY = () => [];
const symbolHandler = {
getOwnPropertyDescriptor: UNDEFINED,
getOwnPropertyNames: ARRAY,
getPrototypeOf: NULL,
setPrototypeOf: FALSE,
defineProperty: FALSE,
deleteProperty: TRUE,
freeze: TRUE,
seal: TRUE,
preventExtensions: TRUE,
isFrozen: TRUE,
isSealed: TRUE,
isExtensible: FALSE,
has: FALSE,
hasOwn: FALSE,
get: UNDEFINED
set: FALSE,
enumerate: ARRAY,
keys: ARRAY,
};
function Symbol(name){
const symbol = new Proxy({}, symbolHandler);
%MarkAsSymbol(symbol, name);
return symbol;
}
It's rare (and pointless) to perform MOP operations on a Symbol because
they're inert. There's no need to optimize those. The optimization that
has to happen is deciding when something is a symbol for the purposes of
property lookup.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss