Kevin Smith (2014-02-13T14:46:05.000Z)
domenic at domenicdenicola.com (2014-02-18T04:38:35.826Z)
I'm not sure to what extent this has been discussed previously, but I think we should consider merging relationships and bind syntax. The relationships strawman introduces two new built-in symbols: @geti and @seti. I will instead use the more descriptive names: `Symbol.referenceGet` and `Symbol.referenceSet`. The basic idea is that arbitrary objects can be used as the "referenced name" in a Reference object. When GetValue or PutValue is called on those kinds of reference objects, behavior is delegated to the functions defined on the "reference name" object at the appropriate symbol. If the required method is not defined on the name object, then an exception is thrown. The operator "::" creates such a reference object. The following code should illustrate the idea: Function.prototype[Symbol.referenceGet] = function(target) { return this }; Map.prototype[Symbol.referenceGet] = function(target) { while (target !== null) { if (this.has(target)) return this.get(target); target = Object.getPrototypeOf(target); } return void 0; }; Map.prototype[Symbol.referenceSet] = Map.prototype.set; // Using a Map as a set of internal fields: var obj = {}; var field = new Map; obj::field = "value"; obj::field; // "value" // Using a function as an extension method: function f() { return this.x; } obj.x = "abc"; obj::f(); // "abc";