I mean if you want to import module dynaically, yon can write it directly into file or use when flag. for example, import streams, strformat let module = readline(stdin) tempFile = getTempDir() & "timeit_temp.nim" var temp = newFileStream(tempFile, fmWrite) temp.writeLine(fmt"import {module}") temp.write(othercode) dicscard execCmdEx(fmt"nim c -r -f --d:{option} --verbosity=0 --hints=off --hint[source]=on " & tempFile) Run
or when defined(this): import this elif defined(that): import that Run