This would require something similar to rust's const generics. IIRC, that's not on the table with the initial draft
On Tuesday, October 6, 2020 at 3:31:46 PM UTC+2 markus....@gain.pro wrote: > It appears to me the current proposal does not allow you to write a > function that sorts an array of any size: > > func SortArray[T comparable](array [??]T, less func(a, b T) bool) [??]T {} > > Is it correct that this is not possible? Or is this expressed differently? > > To clarify, I am seeking for something like: > > func SortArray[T comparable, int n](array [n]T, less func(a, b T) bool) > [n]T {} > > Here's two other examples that come to mind: > > type Number {types ...} > func DotProduct[T Number, int n](a, b [n]T) T {} // n can be any integer > func MultMatVec[T Number, rows, cols int](m [rows][cols]T, v [cols]T) > [rows]T {} > > > Thanks, Markus > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ca5a01f5-41b0-4208-9734-35715008a580n%40googlegroups.com.