Hello All,

I have just responded to [2019 Nim Community 
Survey](https://nim-lang.org/blog/2019/12/20/community-survey-2019.html) and 
got the sense that being more active in the community is appreciated, even 
wanted, so decided to ask for opinions about an issue I have.

I am working on an experimental web framework where I utilize Nim's 
metaprogramming features which I really love. Most things are working very well 
and I am quite happy with the way things are progressing, except this one issue.

Here is what I tried and failed:

The error I got by trying to manipulate the AST is `typechecked nodes may not 
be modified` and when I searched [in the 
code](https://github.com/nim-lang/Nim/blob/13c08f3ab4db3cc7b162af383a74c4fc09f0c378/compiler/vm.nim#L1570),
 I found about `allowSemcheckedAstModification` legacy option.

Since it is marked _legacy_ and the idea of modifying AST that already passed 
semantic checks didn't feel very bright, I went with an alternative solution 
where I call the compiler twice:

  1. I compile app.nim here to generate the AST I wanted, then I write repr 
from that AST into a nim file in the same folder.
  2. Then I compile that generated file.



This is done automatically and not really too bad, but I wonder if anyone would 
suggest something better. I don't know if there is a way to run semcheck again 
manually from inside a macro. That way, every time a new record type is defined 
(.i.e record macro is called) modified AST may be checked again so in that case 
I may use the legacy option without worry.

This is my first message on the forum, but I have browsed through and read a 
lot of discussions. I have started to use Nim more and more in the last few 
months after more than a year of trying it the first time. Just wanted to say 
happy to be here. :) 

Reply via email to