If I wanted to use nim as a modding language for my game, would it be possible to get full safety by using term rewriting macros to rewrite dangerous operations (eg file system access, network access)?
Mods could be distributed as source and the game would ship with the nim compiler. When booting, it would compile the mods into a single dll. When compiling, it would inject term rewriting macros into the source which could be used to capture some operations (eg, force file i/o to only happen in a mod specific folder) or disable some completely (eg interop with C).
I only have a passing knowledge of nim, is this a reasonable approach or is there some big flaw in it? If the sandbox were implemented this way, would it be fallible?