!WgJwmjBNZEXhJnXHXw:matrix.org

TC39 Delegates

243 Members
June meeting: https://github.com/tc39/Reflector/issues/536 Public logs at https://matrixlogs.bakkot.com/8 Servers

Load older messages


SenderMessageTime
11 Oct 2024
@akirose:matrix.orgAkiDo we keep a list of what we consider a stage 4-eligible implementation?02:31:58
@rkirsling:matrix.orgrkirsling> shipping implementations, such as that provided by two independent VMs I feel like this is one of those "has a very concrete meaning in practice and needs to be kept abstract on paper" things02:35:12
@rkirsling:matrix.orgrkirsling(also why tf does Element for Android not all typing formatted text)02:37:29
@rkirsling:matrix.orgrkirsling* (also why tf does Element for Android not allow typing formatted text)02:37:38
@akirose:matrix.orgAkiSo in practice, JSC, SpiderMonkey, or V8 and that's that?02:39:07
@rkirsling:matrix.orgrkirslingin theory others like XS should count but the shipping experience as "proof that the web didn't break" is so important 02:42:48
@ljharb:matrix.orgljharbthey do count when web compat isn’t a concern06:30:16
@ljharb:matrix.orgljharbi have an open PR on the process doc that suggests we should define “risk areas” for each proposal, and use those to inform what counts - ie, what reassurances are most needed06:31:10
@nicolo-ribaudo:matrix.orgnicolo-ribaudoProcess proposal to make a proposal's title blink it it changes Array.prototype06:33:04
@nicolo-ribaudo:matrix.orgnicolo-ribaudo* Process proposal to make a proposal's title blink if it changes Array.prototype06:33:11
@nicolo-ribaudo:matrix.orgnicolo-ribaudo

Weak{Set,Map}.prototype.clone() -- does anybody see any obvious problem with the idea?

My use case is that I need an immutable weakset. For Set it's easy (just do new Set(oldSet).add(newElement), but for weak collections it's quite complex to do it and it involves manually duplicating the contents in a list of WeakRefs

09:01:28
@nicolo-ribaudo:matrix.orgnicolo-ribaudo *

Weak{Set,Map}.prototype.clone() -- does anybody see any obvious problem with the idea?

My use case is that I need an immutable weakset. For Set it's easy (just do new Set(oldSet).add(newElement)), but for weak collections it's quite complex to do it and it involves manually duplicating the contents in a list of WeakRefs

09:01:47
@nicolo-ribaudo:matrix.orgnicolo-ribaudo

My ClonableWeakSet implementation:

class ClonableWeakSet extends WeakSet {
  #contents = [];
    
  #indexes = new WeakMap();

  #cleanup = new FinalizationRegistry(() => {
    if (Math.random() < 0.1) this.#compact();
  });

  #compact() {
    let oldIndex = 0, newIndex = 0;
    while (oldIndex < this.#contents.length) {
      const obj = this.#contents[oldIndex]?.deref();
      if (obj !== undefined) {
        this.#contents[newIndex] = this.#contents[oldIndex];
        this.#indexes.set(obj, newIndex);
        newIndex++;
      }
      oldIndex++;
    }
    this.#contents.length = newIndex;
  }

  add(value) {
    super.add(value);
    if (!this.#indexes.has(value)) {
      this.#indexes.set(value, this.#contents.length);
      this.#contents.push(new WeakRef(value))
      this.#cleanup.register(value);
    }
    return this;
  }

  delete(value) {
    const res = super.delete(value);
    if (this.#indexes.has(value)) {
      this.#contents[this.#indexes.has(value)] = null;
      this.#indexes.delete(value);
      this.#cleanup.unregister(value);
    }
    return res;
  }

  clone() {
    const cloned = new ClonableWeakSet();
    this.#contents.forEach(ref => {
      const obj = ref.deref();
      if (obj !== undefined) cloned.add(obj);
    });
    return cloned;
  }
}
09:02:28
@nicolo-ribaudo:matrix.orgnicolo-ribaudo *

My ClonableWeakSet implementation:

class ClonableWeakSet extends WeakSet {
  #contents = [];
    
  #indexes = new WeakMap();

  #cleanup = new FinalizationRegistry(() => {
    if (Math.random() < 0.1) this.#compact();
  });

  #compact() {
    let oldIndex = 0, newIndex = 0;
    while (oldIndex < this.#contents.length) {
      const obj = this.#contents[oldIndex]?.deref();
      if (obj !== undefined) {
        this.#contents[newIndex] = this.#contents[oldIndex];
        this.#indexes.set(obj, newIndex);
        newIndex++;
      }
      oldIndex++;
    }
    this.#contents.length = newIndex;
  }

  add(value) {
    super.add(value);
    if (!this.#indexes.has(value)) {
      this.#indexes.set(value, this.#contents.length);
      this.#contents.push(new WeakRef(value))
      this.#cleanup.register(value);
    }
    return this;
  }

  delete(value) {
    const res = super.delete(value);
    if (this.#indexes.has(value)) {
      this.#contents[this.#indexes.get(value)] = null;
      this.#indexes.delete(value);
      this.#cleanup.unregister(value);
    }
    return res;
  }

  clone() {
    const cloned = new ClonableWeakSet();
    this.#contents.forEach(ref => {
      const obj = ref.deref();
      if (obj !== undefined) cloned.add(obj);
    });
    return cloned;
  }
}
09:04:10
@ljharb:matrix.orgljharbhow would the values be "cloned"? or would it just put the same === items in both WMs/WSs?09:18:41
@nicolo-ribaudo:matrix.orgnicolo-ribaudoYes 09:19:02
@nicolo-ribaudo:matrix.orgnicolo-ribaudoIt's like doing `new Set(oldSet)`, except that you cannot do this with WeakSets because they are not iterable 09:19:49
@nicolo-ribaudo:matrix.orgnicolo-ribaudo* Yes, same items09:19:59
@nicolo-ribaudo:matrix.orgnicolo-ribaudo * It's like doing new Set(oldSet), except that you cannot do this with WeakSets because they are not iterable 09:20:48
@nicolo-ribaudo:matrix.orgnicolo-ribaudo And this would be much easier to implement in engines than in userland, because engines can iterate over WeakSet contents 09:21:38
@jridgewell:matrix.orgJustin Ridgewell Why not build a wrapper over a WeakSet that prevents writes? 09:31:56
@nicolo-ribaudo:matrix.orgnicolo-ribaudo I trust my code to not mutate the WeakSet, so I don't need to prevent writes 09:32:56
@nicolo-ribaudo:matrix.orgnicolo-ribaudoI need to keep around both the old one and the new one09:33:47
@nicolo-ribaudo:matrix.orgnicolo-ribaudo Oh, I found https://github.com/tc39/proposal-readonly-collections/issues/2. WeakSet.prototype.diverge() is exactly what I need 09:36:47
@gibson042:matrix.orgRichard Gibsonnot all implementations can iterate over WeakSet contents; XS in particular uses an inverted approach that would not support this12:18:34
@yulia:mozilla.orgyuliaima_fac0ac5.jpeg
Download ima_fac0ac5.jpeg
12:20:51
@yulia:mozilla.orgyuliaTg5 workshop photo12:20:55
12 Oct 2024
@ljharb:matrix.orgljharbTemporal change incoming? https://twitter.com/potetotes/status/184442298657479903701:14:33
@shuyuguo:matrix.orgshuif california eminent domains the moon we can just use pacific time07:00:32
@abotella:igalia.comAndreu Botella (at TC39, 🕐 JST)The Sea of Tranquility truly is the Moon's Pacific Ocean07:06:57

There are no newer messages yet.


Back to Room ListRoom Version: 6