Hello,
I have searched the Nim site and this forum trying to read up on deadCodeElim. I am not finding sufficient information for me to understand. Pointers to docs are always welcome. Looking through the manual and compiler or internal guides, I did not find much or overlooked something. I did a quick scan and search for dead.
I am writing an application that will have objects that I write in my modules that will not have any objects created at compile time. I do not want any of these eliminated. They will be created at runtime when a configuration file is read into the app.
I am happy for deadCodeElim on any of my standard library imports and such.
Is their a way to protect specific modules from deadCodeElim and allow others?
What is the proper way to accomplish this?
Thanks for any help, knowledge and wisdom.
I am writing an application that will have objects that I write in my modules that will not have any objects created at compile time. I do not want any of these eliminated. They will be created at runtime when a configuration file is read into the app.
Well either there is a path to construct these objects at runtime or there isn't. If there isn't, dead code elim kicks in. There is no traditional runtime reflection in Nim so this optimization is sound.
You dont need extra protections.
Look at this video, mainly the part about how the AST works: https://www.youtube.com/watch?v=QXjU9qTsYCc
I haven't yet written the part which parses the input config file. I wasn't sure if I would need to do anything special. But as I think on it, you are right. It is definitely a case of premature concern.
Thanks everybody who replied.
Yes. I had read that post. But I didn't find anything conclusive in the thread. It is also 4 years old I didn't know what has or has not changed. I currently do not find any documentation for a deadCodeElim pragma. I could have overlooked it. But I do not see it in the manual or the compiler or internal guides.
Thanks.