I extremely don't like code inline with rules. One of the biggest things in Nitra is clean grammar, so that you can work with language in a straightforward way.
Here is an example:
Here syntax has rule definition, aliases, some behavior definition, which is so similar syntactically, but so different semantically that it requires conscious parsing by brains to understand what is this. I could tell that it violates SOLID in every way possible, but philosophy aside it will be huge nightmare to maintain and evolve.
I propose separation of syntactical and semantic aspects.
- syntax and action should never appear in a same construct
- they can appear in the same file side by side, so they are part of the same language
- actions declarations are like "parts" of same declaration, so you can have one file with all Typing actions and another file with all Formatting actions.
Proposed approach is by defining Calculations