It would be great to hear from those that have written extensive code generation tools as to what changes, if any, Go2 could bring to make code generation easier. Code generation feels more idiomatic to Go. I'm tempted by some kind of package level generics, but I'm terrified that the standard library might end up using them. If I don't like the idea of debugging other people's generics code, i probably shouldn't expect other people's to use mine. I've used syntax-case in scheme, and c++ templates, a reasonable amount. They can lead to concise code, but in both cases I've hated the experience when things go wrong. Operator overloading has a similar effect. Makes code look pretty as you write it, but hard to navigate when your dropped back in it after 6 months. Conversely most of my code generation experience has been pleasant. Maybe we need a dep-like project for generics generation. That could uncover some features that could be useful. The only thing that occurs to me is something akin to C/CPP file and line pragmas for changing the location for errors reported by the compiler maybe?
On Sun, 27 Aug 2017, 16:21 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > While having generics as part of the language and doing the code-gen in > the compiler has definite advantages (ease of use and potentially better > optimization of the generated code), doing it as a separate tool *also* > has advantages. For example, this way no one is bound to whatever notion of > generics will eventually be built into the language. Because it *will* > have limitations and provide a trade-off. With separate tooling outside the > language, people can make their own tradeoff. > > For example, yes, you can do template-like code generation at compile > time. But you could also box values in interface{} and have a tool that > verifies your desired notion of type-saftey statically. It's up to you - > whatever makes more sense for your use case. > > Honestly, right now I'd prefer good and easy to use meta-programming tools > for go. If I can write my own type-checks or code-gen to be run on a go > build, it enables far more powerful tools than generics alone… (yes, it > also has drawbacks. I'm aware). > > On Sun, Aug 27, 2017 at 5:08 PM, <prades.m...@gmail.com> wrote: > >> > That's how C++ started. >> >> And that's also why C++ is the ugly monster than it is today; with a >> design that wasn't quite thought thoroughly. Talking about C++ like it's an >> example to follow is just preposterous. >> >> Le dimanche 27 août 2017 16:25:54 UTC+2, Jan Mercl a écrit : >>> >>> And there's nothing wrong in it. That's how C++ started. Codegen allows >>> for easier protoyping throwaway experiments. Writing a full blown compiler >>> and realizing afterwards a better language/feature design costs probably >>> much more work. >>> >>> On Sun, Aug 27, 2017, 15:55 <prade...@gmail.com> wrote: >>> >>>> > Codegen can do 100% of what any compiler can do. >>>> >>>> Yes and it is called doing the compiler's job in place of it. >>>> >>>> -- >>>> 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...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >>> >>> -j >>> >> -- >> 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. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.