Hello! I just ran into a problem that is solved really nicely with the new generics proposal and I thought someone might find it interesting :D
I was trying to implement a library for doing ascii art programmatically. The main struct is basically an image.Image except it works with bytes instead of colors. As such you /should/ be able to create functions (like a flood fill algorithm) that are abstracted over both of these types, but without "generics" this cannot be done (with compile time type safety). I sketched a little project <https://go2goplay.golang.org/p/68KmGdqIVoc> in the go2go playground that implements generic functions for doing Porter-Duff compositions <http://ssp.impulsetrain.com/porterduff.html> on any types that fulfill the following constraint: ``` type Rect(type T comparable) interface { At(x, y int) T Set(x, y int, t T) } ``` Type defs on lines [8, 13]. Porter-Duff implementation [15, 99] Main [101, 108] ByteImg implementation [110, 185] I liked this example because it requires passing a generic function (the Porter-Duff func) to another generic function (Merge) :D I hope someone else finds it interesting as well! --Beka -- 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/dbc90697-e276-437b-ab39-b52564fc6d5an%40googlegroups.com.