I tested this with Nim v1.0.6 on Windows 8.1.

Build nimhcr.dll and nimrtl.dll: 
    
    
    cd c:\my\path\to\nim
    nim c -d:release lib/nimrtl.nim
    nim c -d:release lib/nimhcr.nim
    
    
    Run

Put them in the parent directory of mymain.nim or an directory PATH env var 
contain. As sample code in the 
[instructions](https://nim-lang.github.io/Nim/hcr) failed to compile, I tested 
following code.
    
    
    #logic.nim
    #*** import the hotcodereloading stdlib module ***
    import hotcodereloading
    import os, times
    
    var lastMod = getLastModificationTime(currentSourcePath())
    
    proc update*() =
      echo "bar"
      let t = getLastModificationTime(currentSourcePath())
      if t > lastMod:
        if execShellCmd("nim c --hotcodereloading:on mymain.nim") == 0:
          lastMod = t
          #*** reload this logic.nim module on this file updated.***
          performCodeReload()
      sleep 1000
    
    
    Run
    
    
    #mymain.nim
    
    import logic
    
    proc main() =
      while true:
        update()
    
    main()
    
    
    Run

Build mymain.nim and run mymain.exe: 
    
    
    nim c --hotcodereloading:on mymain.nim
    mymain.exe
    
    
    Run

Change code in logic.nim from
    
    
    echo "bar"
    
    
    Run

to
    
    
    echo "foo"
    
    
    Run

When I save it to the file, it is rebuilt and reloaded automatically.

Reply via email to