3 ms·
> setting up all the types for the channels based on the types in the functions being run by the go routines was quite difficult. I had to do it all by reflecti
by bpizzi 8y ago
> setting up all the types for the channels based on the types in the functions being run by the go routines was quite difficult. I had to do it all by reflection and the code was really complicated.
My guess (and personal experience) is that this would maybe be more convenient to do this via code generation. It's not as ergonomic as generics (well, depending on the implementation...), but still it's less cumbersome and prone to failing at runtime that reflection.
Reflection has its uses and places, but as soon as it gets all over a function then it's time (imho) to look into code generation.
- mikekchar 8y agoI definitely would have done it that way, but there was no standard code generation in go at the time. I could have whipped something up it's hard to say which would have been more complex.
- bpizzi 8y agoAs an anecdote: my 'code generation' go-to solution in go is text/template's based. The '//go generate' on the first line of the source file generating the final code is a mere helper and I could do without it any time. Again that's just my experience ;)