Alright, another stab at this. This time I tried using `fsnotify` instead. Same 
behavior. Most of the time it works, but I get the occasional segfault.

mymain.nim 
    
    
    import logic
    import fsnotify
    import osproc
    
    proc cb(event: seq[PathEvent]) =
      echo "saved"
      echo execProcess("nim c --hotcodereloading:on mymain.nim")
      update(true)
      echo "reloaded"
    
    # file watcher stuff
    proc main() =
      var watcher = initWatcher(1)
      watcher.register("logic.nim", cb, ms = 100)
      
      while true:
        poll(watcher, 2000)
        update(false)
    
    main()
    
    
    Run

logic.nim: 
    
    
    import hotcodereloading, strformat
    var reloaded = 0
    
    proc update*(reload: bool) =
      if reload:
        performCodeReload()
        reloaded += 1
        echo fmt"reloaded {reloaded} times......."
    
    
    Run

I tried just commenting out the `update` function call in mymain, so its just 
mymain code - and it works fine. I never got it to crash that way.

I'd be interested to hear from more non-OSX users.

Reply via email to