On Tue, 16 Oct 2018 08:39:32 -0700 (PDT) Eric Raymond <[email protected]> wrote:
> New rule: A function on variables of undefined formal-argument types > compiles to a template (not a textual template - we don't want identifier > capture). At each callsite of the function, the undefined types in the > formals are bound to the types of the arguments in the call. If every > operation in the resulting code is defined, the code compiles as if the > generic function had been written with the actual argument types at the > callsite. If not, the compiler throws an error on each undefined > operation. Sounds like implementation sketch of my CGG proposal at https://github.com/ohir/gonerics (https://github.com/ohir/gonerics/blob/master/howdoes.md) I am happy to see another soul that see there is no need for filling type parameters at call site. > Call me crazy, but I think we just got parametric polymorphism > with zero additional complexity load on the rest of the language. I am eager to see one of CGG critics explaining to you that it is not "because it is not how it is done in Java". ;) > As the meme goes, "Prove me wrong". If nobody does, we now have both > parametric polymorphism and a complementary contract system at the cost of > one (1) new keyword and (1) interaction with the rest of the design - > overloading pointer types has to be forbidden in order not to break ==. . Anyway, "Implements" is a form of contract. As much as CGG's "for type". Ah, and CGG has one less new keyword ;) But I like your approach. Right after mine's. TC, -- Wojciech S. Czarnecki << ^oo^ >> OHIR-RIPE -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
