dplassgit / d2lang

D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
MIT License
6 stars 1 forks source link

Implement generics/parameterized records #291

Open dplassgit opened 8 months ago

dplassgit commented 8 months ago

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.

dplassgit commented 8 months ago

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

dplassgit commented 8 months ago

but what about

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

???