4 ms·
It doesn't really happen all that often in practice, and when you're hacking on a package that relies on this it's easy enough to have `go generate && go test`
by dsymonds 12y ago
It doesn't really happen all that often in practice, and when you're hacking on a package that relies on this it's easy enough to have `go generate && go test` sitting in your shell history for that iteration cycle.
- dilap 12y agoWell, I think the jury's still out, since there hasn't been a lot of use in the wild yet. I realize it can be quite frustrating to get negative feedback from people who haven't even used a feature yet, so I hope I'm not coming across as overly negative. I am overall a huge fan of Go :) And I do appreciate the minimalistic nature of the approach... I expect we'll start to see people do a lot of generics-type stuff with this -- e.g., add an go:generate annotation to get a customized Foo collection or whatever. It'll be interesting to see how it shakes out.
- blakecaldwell 12y agoI imagine most of the complaining is by people that haven't even spent much time in the language, let alone this new tool. I'm would wager that generics were a driving force behind this. They don't want to add them to the language (fair), but are willing to offer a way for us to add them at precompile time.
- mseepgood 12y ago> I'm would wager that generics were a driving force behind this. The driving forces were yacc, protocol buffers, enum strings, unicode tables, encoding/decoding arrays, time zone data. That's what they use it for.
- lomnakkus 12y agoHow would that work? AFAIU the idea is that library authors check in the generated code -- so a consumer of your code wouldn't be able to (or at least would be actively discouraged from) generate new code for a library. And thus wouldn't be able to generate "instances" for generic code.
- blakecaldwell 12y agoI haven't spent much time looking into this, and haven't used it yet, but from the Stringer example, they're providing us with a tool to generate strings for enum values. That same approach could be used to generate support for typed collections for your types. I could make the collection-generating code, and you could generate the collections for your types.
- lomnakkus 12y agoYeah, for your types, but if I'm a provider of a library of generic data structures (which is what the people asking for generics are probably thinking about), you're out of luck since I have no way of letting you generate appropriate instances.