tag:blogger.com,1999:blog-4892209359042715256.post4205579933705314497..comments2022-10-14T21:49:00.732+05:30Comments on One of Many Worlds: Draft 2 of a proposal for generics in GoAnonymoushttp://www.blogger.com/profile/15731991685864379412noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-4892209359042715256.post-90863568755275661592012-05-03T08:58:11.735+05:302012-05-03T08:58:11.735+05:30Thanks for the comment Glenn! Yes, perhaps `<T...Thanks for the comment Glenn! Yes, perhaps `<T>' isn't the best syntax. I am fine with any unambiguous syntax. On the latter point, though, you may have noticed that I expressly do <b>not</b> propose user-definable interface-like behaviour for primitive types. The proposed type classes are compiler magic. My proposal also assumes that Go will <b>not</b> have an equivalence between operators and methods (implied by interfaces).Anonymoushttps://www.blogger.com/profile/15731991685864379412noreply@blogger.comtag:blogger.com,1999:blog-4892209359042715256.post-33054872546105084712012-05-02T04:52:22.121+05:302012-05-02T04:52:22.121+05:30That should be "'<T>' syntax&qu...That should be "'<T>' syntax", not "'' syntax" but blogspot ate the apparent-html markup...Gln Brwnhttps://www.blogger.com/profile/05626694096123850629noreply@blogger.comtag:blogger.com,1999:blog-4892209359042715256.post-51777075834289639492012-05-02T04:49:26.943+05:302012-05-02T04:49:26.943+05:30In my experiments with the grammar, I found the &#...In my experiments with the grammar, I found the '' syntax to be incompatible with semicolon insertion, but that '~(T)' worked, and could be simplified to ~T when T is a simple type name.<br /><br />Haskell uses type classes ( http://learnyouahaskell.com/types-and-typeclasses#typeclasses-101 ) . We'd do well to consider them.<br /><br />Your idea of type classes for basic types could naturally be extended to interfaces by defining an interface{..} for each type class, but only if something like 'receiver type matching' a.k.a 'Generic Operators' at http://learnyouahaskell.com/types-and-typeclasses#typeclasses-101 were implemented. But if one does this and also adds inter-module inlining of small methods, which seems inevitable in the long run, then you can write generics to the interface instead of using basic operators like '<' and '==' and not sacrifice runtime performance. To me, this seems the simplest full-featured design.<br /><br /><br /> write generics to the interface (instead of using basic operators like '<' and '==') to avoid havingGln Brwnhttps://www.blogger.com/profile/05626694096123850629noreply@blogger.com