You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have many operations that "map" a heterogeneous array through a function that transforms elements. (See #114 for some examples).
The heterogeneous arrays have a var storage: [ObjectIdentifier: Something] field that stores their elements. There are two ways that the map operations could produce the storage for the resulting heterogeneous arrays:
Transform the Somethings, but leave the ObjectIdentifiers unchanged (even if the transform changes the type of the elements).
Transform the Somethings, and also transform the ObjectIdentifier to the identifier of the transformed element type.
Option 1 has the drawback that the resulting ObjectIdentifier no longer matches the element type and therefore the subscript using TypedID, which assumes that the ObjectIdentifier matches the element type, can't index into the result heterogeneous array. Option 2 has the drawback that ObjectIdentifiers can collide if the transform function maps distinct types to the same type.
We actually currently use both options in different places, depending on what we need. In the place where we use option 2, we don't handle collisions so we should really fix it soon (none of the use cases that we have implemented so far cause collisions).
The correct solution is probably to use option 1 but add additional data to TypedID so that we can subscript into the resulting arrays using TypedID.
The text was updated successfully, but these errors were encountered:
We have many operations that "map" a heterogeneous array through a function that transforms elements. (See #114 for some examples).
The heterogeneous arrays have a
var storage: [ObjectIdentifier: Something]
field that stores their elements. There are two ways that the map operations could produce thestorage
for the resulting heterogeneous arrays:Something
s, but leave theObjectIdentifier
s unchanged (even if the transform changes the type of the elements).Something
s, and also transform theObjectIdentifier
to the identifier of the transformed element type.Option 1 has the drawback that the resulting
ObjectIdentifier
no longer matches the element type and therefore the subscript usingTypedID
, which assumes that theObjectIdentifier
matches the element type, can't index into the result heterogeneous array. Option 2 has the drawback thatObjectIdentifier
s can collide if the transform function maps distinct types to the same type.We actually currently use both options in different places, depending on what we need. In the place where we use option 2, we don't handle collisions so we should really fix it soon (none of the use cases that we have implemented so far cause collisions).
The correct solution is probably to use option 1 but add additional data to
TypedID
so that we can subscript into the resulting arrays usingTypedID
.The text was updated successfully, but these errors were encountered: