#2651 Annotation processing

Marcio Fri 6 Oct 2017

Does Fantom support Annotation Processing?

Thanks

SlimerDude Fri 6 Oct 2017

Hi Marcio,

In Fantom, annotations are called Facets and may exist on a Class or a Slot (Field or Method).

As for Annotation Processing, taking this definition from StackOverflow:

"Annotation Processing" is a hook into the compile process of the java compiler, to analyse the source code for user defined annotations and handle then (by producing compiler errors, compiler warning, emmiting source code, byte code ...)

Then no, Fantom does not have Annotation Processing or compiler plugins.

But it does have limited support for defining your own syntax via DSLs. A good write up on Fantom DSL Processing is available here:

Exploring Fantom DSLs

As I mention in the Future Fantom topic I personally am not a huge fan of DSLs and think the API to the compiler could do with more thought.

On another level, the Fantom compiler is written in... Fantom! That means you're able to dynamically generate Fantom source code and compile it on the fly! That is the principle of the efan library.

Hope this helps.

Marcio Fri 6 Oct 2017

If I correctly understood, efan uses code generation at runtime and not compile time. It would be nice if Fantom had some kind of Macro support for code generation at compile time.

Thanks!

SlimerDude Fri 6 Oct 2017

efan uses code generation at runtime and not compile time

That's correct, yes.

would be nice if Fantom had (...) support for code generation at compile time.

I agree. I argue the case for it in my first comment in the Questions about Fantom future topic. Essentially it would be a powerful tool that would help prevent people from asking for feature requests by letting them program the features themselves.

Login or Signup to reply.