dplassgit/d2lang

Implement generics/parameterized records

Opened this issue · 3 comments

At least something like:

// Doubly-linked list
List: record<Type> {
   entry: Type
   prev: List<Type>
   next: List<Type>
}

list  = new List<int>
list.entry = 3
list.prev = null
list.next = null

second = new List<int>
second.entry = 4
second.prev = list
list.next = second

and it Just Works.

I think this would be more impactful than many of the other OO-themed issues.

but what about

func: proc(list : List<Type>): Type {
   return list.entry
}

???