typed-objects-explainer icon indicating copy to clipboard operation
typed-objects-explainer copied to clipboard

Referencing structs embedded within other structs

Open phpnode opened this issue 9 years ago • 0 comments
trafficstars

Given these structs:

const Point = new StructType({
  x: float64,
  y: float64
});
const Series = new StructType(Point, 100);

const Line = new StructType({
  from: Point.ref,
  to: Point.ref
});

Should an instance of Line be able to refer to a Point embedded within an instance of Series?

e.g.

const series = new Series();
const line = new Line({from: series[0], to: series[1]});

I would argue that it shouldn't be possible, because the location it is referring to is dependent on the layout of the container, which can be subject to change (if it's something like a bucket in a hash map for example). Does anyone disagree? I haven't seen this restriction mentioned so far.

phpnode avatar Feb 24 '16 18:02 phpnode