r/ProgrammingLanguages • u/RedCrafter_LP • May 14 '26
Help Compile time evaluation
I want to include compile time evaluation in my language.
For context I have most of the language design and compiler planned out and am currently implementing it. Currently writing the parser that turns a stream of tokens into the ast. The plan is to target llvm ir for the moment.
While I have enough to do before I have to address it I want to get some information about executing code at compile time. I am explicitly not talking about macros for them I already have an idea. My questions are:
- How to decide rather to execute a function or keep the call in code
- Security concern about access to the system on compile time evaluation
- How to execute it without writing a separate interpreter
- Does llvm provide any supporting features for this
Thanks
19
Upvotes
View all comments
Show parent comment
0
u/RedCrafter_LP May 14 '26
My macros work on the ast level meaning they are not really suitable for use in for example just a constant initialization. They are rather expensive and limiting as well which is why const functions should do the normal stuff fully implicitly.