tc39/proposal-pattern-matching

Spec: Use Map instead of WeakMap

Jack-Works opened this issue · 4 comments

since we're redesign this proposal, we can do it in the next rewrite

ljharb commented

Wait, why this change? We want things to be held weakly, no?

bathos commented

Am I correct to guess the difference would become observable only if yielding within a match?

Wait, why this change? We want things to be held weakly, no?

It was the decision made from the previous discussion. It is also not observable (Map or WeakMap) anyway, because it's impossible (if we don't have a bug in the spec) to leak the cache object to the userland.

I cannot recall the reason why someone want Map not WeakMap, maybe it's related to GC stuff.

Am I correct to guess the difference would become observable only if yielding within a match?

Oh, maybe it is observable I'm not sure, if await or yield happened inside a match, but in this case, I think it would be better to keep things strongly held, otherwise, the match might behave in a strange way.