See https://gist.github.com/rightfold/a4122970bb4587d3bd01 for C++ data structures.
type nil_type;
nil_type.size = 8;
nil_type.alignment = 8;
nil_type.fields = [];
nil_type.move = no-op;
type cons_type;
cons_type.size = 24;
cons_type.alignment = 8;
cons_type.fields = [
car: { size = 8; alignment = 8 },
cdr: { size = 8; alignment = 8 },
];
cons_type.move = memmove;
bytes 1..8 |
bytes 9..16 |
bytes 17..24 |
&cons_type |
&1 |
&2 |
type string_type;
string_type.size = 24;
string_type.alignment = 8;
string_type.fields = [];
string_type.move = [] (void* fromp, void* top) {
std::string* from = (std::string*)((char*)fromp + 8);
std::string* to = (std::string*)((char*)fromp + 8);
std::string temp(std::move(*from));
*to = std::move(temp);
};
bytes 1..8 |
bytes 9..9+sizeof(std::string) |
&string_type |
std::string data |