I was wondering if there will be native support for code generation. The idea here is, that one can make fantontemplate files, which will be expanded at compile time to fantom source code. This code will be compiled along with normal source code.
While code generation itself has its merits and is used more and more frequently in industry,
it may also solve the issues I and many others have with the lack of generics. We can simply create a template class and fill the class name and the type with whatever we need without changing the type system!
The generated files should have a header clearly telling that the file has been autogenerated. Further, there should be an encoding telling which template the file stems, such that deleting a templatefile will make it easy to delete its resulting source files.
The "T4" project for C# is along the lines I'm thinking. Further, it has the neat feature that opening a project with templates, VisualStudio automatically generates the templates to source files and includes them in the project as though they were part of the project from the start.
brianTue 22 Feb 2011
Hi @kbilsted, welcome to Fantom!
If you would like to generate code, there are already lots of options for turning that code into loaded classes:
Env.compileScript
compiler API is fully available
build scripts to create full fledged pods
Was there something else specifically you were looking for?
I am not sure its a core thing for how you generate the code and what templating engine you use (might take a look at Mustache), unless one obvious community project stands out as belonging in the core. In fact, my plan for later this year is to slice up the existing core into a much smaller distribution and move things like UI, flux, etc out into online repositories. Long and short - my goal is to start making "core" smaller, not bigger (but we need to figure out online repo design first).
kbilsted Mon 21 Feb 2011
Hello All.
I was wondering if there will be native support for code generation. The idea here is, that one can make fantontemplate files, which will be expanded at compile time to fantom source code. This code will be compiled along with normal source code.
The generated files should have a header clearly telling that the file has been autogenerated. Further, there should be an encoding telling which template the file stems, such that deleting a templatefile will make it easy to delete its resulting source files.
The "T4" project for C# is along the lines I'm thinking. Further, it has the neat feature that opening a project with templates, VisualStudio automatically generates the templates to source files and includes them in the project as though they were part of the project from the start.
brian Tue 22 Feb 2011
Hi @kbilsted, welcome to Fantom!
If you would like to generate code, there are already lots of options for turning that code into loaded classes:
Was there something else specifically you were looking for?
I am not sure its a core thing for how you generate the code and what templating engine you use (might take a look at Mustache), unless one obvious community project stands out as belonging in the core. In fact, my plan for later this year is to slice up the existing core into a much smaller distribution and move things like UI, flux, etc out into online repositories. Long and short - my goal is to start making "core" smaller, not bigger (but we need to figure out online repo design first).