Skip to content
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

Struct #45

Closed
skas102 opened this issue Apr 11, 2019 · 3 comments
Closed

Struct #45

skas102 opened this issue Apr 11, 2019 · 3 comments
Assignees
Labels
implementation Implementation task

Comments

@skas102
Copy link
Collaborator

skas102 commented Apr 11, 2019

Structs should be supported.

Struct Declaration:

struct Person {
 string name
 int balance
}

Struct Creation:

new Person()
new Person("test", 120)
new Person(name="test", balance=120)

Struct Usage:

Person p = new Person()
p.name = "test"           // Assignment using member access designator
string name = p.name // Read value using member access expression
@skas102
Copy link
Collaborator Author

skas102 commented Apr 21, 2019

This story also includes:

  • Testing of member access in the generator

@tk-codes tk-codes self-assigned this Apr 23, 2019
@skas102
Copy link
Collaborator Author

skas102 commented May 3, 2019

Wir können das Problem folgendermassen lösen:

  • Auf jedem Struct gibt es ein zusätzliches Property: is_default welches mit True initialisiert wird. Sobald dass Struct zugewiesen wird wird dieses Property auf false gesetzt. Der Benutzer kann dann dieses Property abfragen.

Everytime an uninitialized property is accessed, we initialize it before accessing it e.g.

struct Person {
  name: string // default ""
  age: int  // default 0
  father: Person. // nil until accessed
}

p = new Person() // name = "", age = 0, father = nil
p.name = "Max"
p.father.name = "Maximilian" -> Initialize father with the Default Person Struct when accessing it for the first time.

@tk-codes
Copy link
Collaborator

tk-codes commented May 8, 2019

Done. Default struct initialization should be implemented in VM (bazo-blockchain/bazo-vm#38)

@tk-codes tk-codes closed this as completed May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implementation Implementation task
Projects
None yet
Development

No branches or pull requests

2 participants