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

Generic Record Declaration #97

Open
Alexius-Huang opened this issue May 30, 2020 · 0 comments
Open

Generic Record Declaration #97

Alexius-Huang opened this issue May 30, 2020 · 0 comments

Comments

@Alexius-Huang
Copy link
Owner

What?
Generic record which have flexible variation.

Why?
Generics are standard feature in typed programming language.

How?
Sample Wyrd Code

record Node<T> { T value, maybe Node<T> next }
record LinkedList<T> { Node<T> head }

n1 = Node<Num> { value: 1 }
n2 = Node<Num> { value: 2  }
n3 = Node<Num> { value: 3  }

n1->next = n2
n2->next = n3
numberList = LinkedList<Num>{ head:  n1 }

Compiled Result

const n1 = { value: 1, next: null };
const n2 = { value: 2, next: null };
const n3 = { value: 3, next: null };
n1.next = n2;
n2.next = n3;
numberList = { head: n1 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant