Hot code reloading

  1. module main
  2. import time
  3. import os
  4. [live]
  5. fn print_message() {
  6. println('Hello! Modify this message while the program is running.')
  7. }
  8. fn main() {
  9. for {
  10. print_message()
  11. time.sleep_ms(500)
  12. }
  13. }

Build this example with v -live message.v.

Functions that you want to be reloaded must have [live] attribute before their definition.

Right now it’s not possible to modify types while the program is running.

More examples, including a graphical application: github.com/vlang/v/tree/master/examples/hot_code_reload.