Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Agreed, though I think the syntax problem (too many parens) could be made more readable and Go-like by emphasizing the generic aspect and making it stand out visually -- leaving no doubt that you're in a section that's generic, and perhaps dissuading overuse by making it noisy. Perhaps something like:

  generic func(T, U) Map(slice []T, mapper func(T) U) []U
For "contracts":

  type Set generic interface(T comparable) {
    Push(T)
    Pop() T
  }
Every time you want to refer to a generic type you'd have to use the generic keyword, which encourages use of concrete types:

  type IntSet generic Set(int)
This is more or less how Modula-3 does it. Generics have dedicated syntax with a "generic" keyword.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: