Nope, I meant pre-compile time generation. Runtime generation removes type safety and doesn't get us much more than using interface{} and casts.
It would be a manual step before compile that writes out to the file new function definitions with the appropriate types replaced and then you could compile and run normally. There would be no problem with the debugger or anything during runtime because there would be actual code on disk for every function. What the code generation does is let you have one definitive version of the code and then replicate it with carefully controlled changes to simulate templates (generics).
Nope, I meant pre-compile time generation. Runtime generation removes type safety and doesn't get us much more than using interface{} and casts.
It would be a manual step before compile that writes out to the file new function definitions with the appropriate types replaced and then you could compile and run normally. There would be no problem with the debugger or anything during runtime because there would be actual code on disk for every function. What the code generation does is let you have one definitive version of the code and then replicate it with carefully controlled changes to simulate templates (generics).
--
Gotgo already does this templating.
--
--
--
Ahh but you see - the template code is valid go code. In the template you use interface{} or a custom defined interface. The template code then can call methods on the interface (or in the case of the empty interface - you can't). That's actually what ensures the generated code will also compile - the template code had to compile.
You put markers in comments around the template to let the code generator know it's a template.
Sorry no time for an example right now, I'll write one out in the morning.
--