tc39 / proposal-structs

JavaScript Structs: Fixed Layout Objects
http://tc39.es/proposal-structs/
239 stars 5 forks source link

Interaction with object references from primitives #10

Closed acutmore closed 2 years ago

acutmore commented 2 years ago

A curiosity more than an 'issue'. The Record&Tuple proposal could end up introducing primitives that contain references to objects.

What do we think should happen when these interact with shared structs?

shared struct class Structy {
  x;
  constructor(x) {
    this.x = #[1, 2, 3, Box({})];
  }
}

Would it immediately throw as this isn't deeply primitive?

EDIT: clarify shared struct

acutmore commented 2 years ago

Just seen that it is already the case that Symbols are not allowed in shared struct. So already have a case where a primitive throws. So Box does not really introduce anything new here 🙂

ljharb commented 2 years ago

@acutmore tbf it's still new even if there's a dozen stage 1 proposals that add it :-p