18:12
<bakkot>
function f(){}
let sym = Symbol();
f[Symbol.toPrimitive] = () => sym;
let o = { [sym]: 0 };
console.log(o[f]) // 0

... hm

18:13
<bakkot>
keying objects by functions
18:13
<bakkot>
kinda fun
18:13
<shu>
cursed
18:27
<bakkot>
let functorMapSymbol = Symbol('Functor.map');
let Functor = {};
Functor.map = function(rec, ...args){ return rec[functorMapSymbol](...args); };
Functor.map[Symbol.toPrimitive] = () => functorMapSymbol;

let o = {
  [Functor.map](arg) {
    console.log(arg);
  },
};

// usage:
o[Functor.map]('hi');

// alternative usage:
Functor.map(o, 'hi');
18:29
<Francisco Tolmasky>
I actually do something similar to that all the time. Also use it to "carry" information in properties, something like { [property 'my-prop' ({ enumerable: false })\]: 10 }\
18:30
<Francisco Tolmasky>
dont know how to nest backticks, but you get the idea, you can have a function that creates metadata, then creates a custom symbol on the fly, associates the metadata to the custom symbol in a weakmap, then returns the custom symbol, then on the other end you can use it to retrieve the metadata
18:32
<Francisco Tolmasky>
for example like Schema({ [property 'whatever'.readonly]: 10 }) (Schema then knows how to retrieve the metadata and construct the property descriptor from it to create the property on itself