<div dir="ltr">The struct-copy docs say &quot;The result of struct-expr can be an instance of a sub-type of id, but the resulting copy is an immediate instance of id (not the sub-type).&quot; Why is this?<div><br></div><div>

For instance, I would hope this would work:</div><div><br></div><div><div>(struct posn (x y))</div><div>(struct 3d-posn posn (z))</div><div>(3d-posn-z (struct-copy posn (3d-posn 1 2 3) [x 5]))</div></div><div><br></div><div style>

My actual use case is that I&#39;m representing some data with structs. I have the common data in a parent struct and the specific data in the child structs. One of the common fields is a unique id (a number I just increment). I&#39;d like to be able to copy a piece of data and just change the unique id in the struct-copy. Instead I have to have a cond or a match that does the same struct-copy but with different struct ids for each sub type.</div>

<div style><br></div><div style>Is there an easier way to do what I&#39;m trying to do?</div></div>