3 ms·
Indeed. Why mix two grammars in one file? Now, that "go generate" call has to parse go (at least up to comments; I think it should ignore "//go:generate" inside
by Someone 12y ago
Indeed. Why mix two grammars in one file? Now, that "go generate" call has to parse go (at least up to comments; I think it should ignore "//go:generate" inside multi-line strings), and then parse those comments.
I would think it would be way simpler to only allow those special comments in the input file for "go generate".
If I were snarky, I would add that, if this gets used a lot, it might be handy to add dependency information to that file, so that "go generate" can skip repeated work. Once it does that, people can call it every time they compile their code, gaining convenience without much loss of time.
I also wonder what the distribution of code will look like. The goal seems to be to shield ordinary programmers from code generation. That is somewhat laudable (I would like to see a 'layered' language where upper layers are highly similar, but simpler to use and a bit less powerful, but haven't seen a good one yet), but at odds with the GPL. I think the GPL will require you to distribute the master code.
When used as an alternative for generics, distributing only the generated code also will lead to diverging of the various generated versions. People will fork and then modify only eight of those ten generated files.