We need structs in the language. Structs in Corth will be stored in the stack and when we have a better way to create variables, we will add struct pointers etc. This should probably not be priority until types are improved.
// Defining a struct
struct Employee
int id
int salary
end
// Constructing a struct
3 3800 make Employee
// Get the value of a field in the struct
3 3800 make Employee let emp in
emp get id putu
// ...or...
emp get Employee id putu
end
// Set the value of a field in the struct
3 3800 make Employee let emp in
4 emp set id
// ...or...
4 emp set Employee id
end
We need structs in the language. Structs in Corth will be stored in the stack and when we have a better way to create variables, we will add struct pointers etc. This should probably not be priority until types are improved.