Tagless overlapping storage for one value chosen from a fixed list of schemas.
Construct with a schema list in tuple form, for example (Int32 Nat8) Union.
Items: list of supported schemas.data: raw aligned storage for the selected interpretation.pad: remaining storage needed to reach the maximum item size.get (key -- ref): returns one Ref to the overlapping storage interpreted as the schema at key.MAXIMUM_ALIGNMENT: greatest alignment among the supported schemas.MAXIMUM_SIZE: greatest storage size among the supported schemas."Union" use
"control" use
{} () {} [
u: (Int32 Nat8) Union;
0 @u.get printStack _:;
1 @u.get printStack _:;
] "main" exportFunction
Int32 Ref
Nat8 Ref
"Union" use
"String" use
"control" use
{} Int32 {} [
u: (Int32 Nat8) Union;
123 0 @u.get set
("int=" 0 @u.get new LF) printList
7n8 1 @u.get set
("nat=" 1 @u.get new LF) printList
0
] "main" exportFunction
int=123
nat=7
"Union" use
"String" use
"control" use
{} Int32 {} [
u: (Int32 Nat32) Union;
-1 0 @u.get set
("asInt=" 0 @u.get new LF
"asNat=" 1 @u.get new LF) printList
0
] "main" exportFunction
asInt=-1
asNat=4294967295
Union has no tag and does not track which schema was written last.get call returns one typed view of the same overlapping storage.MAXIMUM_ALIGNMENT and MAXIMUM_SIZE are derived from the supported schema list and determine the storage layout.