Skip to content

Structs #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
HuseyinSimsek7904 opened this issue Nov 26, 2023 · 0 comments
Open

Structs #20

HuseyinSimsek7904 opened this issue Nov 26, 2023 · 0 comments
Assignees
Labels
compiler Anything about the compiler enhancement New feature or request high-priority

Comments

@HuseyinSimsek7904
Copy link
Member

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
@HuseyinSimsek7904 HuseyinSimsek7904 added the enhancement New feature or request label Nov 26, 2023
@HuseyinSimsek7904 HuseyinSimsek7904 self-assigned this Nov 26, 2023
@HuseyinSimsek7904 HuseyinSimsek7904 added the compiler Anything about the compiler label Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Anything about the compiler enhancement New feature or request high-priority
Projects
None yet
Development

No branches or pull requests

1 participant