
Generally, in Erlang or Haskell, the semantics we use is to keep all the old code in memory, for the case of closures and thunks that point back into that code. You can imagine a fine-grained semantics where as each top level function is no longer referenced, the *code* for that is swapped. I believe there have been versions of Erlang bytecode hotswapping that supported that. In GHC Haskell, we have component-level hotswapping -- only whole-modules may be swapped out at the moment. As we can't unload code based on the GC dropping references, we just keep it all in memory, migrating to new code as *new* (dynamic) bindings are introduced. The type migration issue is yet another problem. There are several approaches to migrating state types, including serialization (as xmonad et al do), or using open data types. -- Don nominolo:
What would be the semantics of hot-swapping? For, example, somewhere in memory you have a thunk of expression e. Now the user wants to upgrade e to e'. Would you require all thunks to be modified? A similar problem occurs with stack frames.
You'd also have to make sure that e and e' have the same (or compatible types). e' most likely has different free variables than e, how can you translate thunk one to the other?
Now assuming you don't try to do this, how would you handle the case when something goes wrong?
On 16 July 2010 04:05, Andy Stewart
wrote: Hi all,
I'm research to build a hot-swap Haskell program to developing itself in Runtime, like Emacs.
Essentially, Yi/Xmonad/dyre solution is "replace currently executing" technology:
re-compile new code with new binary entry
when re-compile success $ do save state before re-launch new entry replace current entry with new binary entry (executeFile) store state after re-launch new entry
There are some problems with re-compile solution:
1) You can't save *all* state with some FFI code, such as gtk2hs, you can't save state of GTK+ widget. You will lost some state after re-launch new entry.
2) Sometimes re-execute is un-acceptable, example, you running some command in temrinal before you re-compile, you need re-execute command to restore state after re-launch, in this situation re-execute command is un-acceptable.
I wonder have a better way that hot-swapping new code without re-compile/reboot.
Thanks,
-- Andy
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- If it looks like a duck, and quacks like a duck, we have at least to consider the possibility that we have a small aquatic bird of the family Anatidae on our hands. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe