V: More documentation regarding hot reloading ?!!!

Created on 18 Mar 2019  路  1Comment  路  Source: vlang/v

My mind can't grasp the concept behind doing hot reloading without doing a compile!!!
At first I thought it was a joke, but I guess it's not.
Could you please explain further the concept at least briefly.

Most helpful comment

Good question. I'll add info about it to the docs.

Let's say you have

#!hot

fn main() {
    for {
        foo()
        time.sleep(1)
    }
}

fn foo() {
    println(1)
}

It will print number 1 every second.

However since we used the hot directive (name is not final 馃槂), foo() is loaded dynamically, and V will insert a small program that will run in the background and wait for modifications in main.v. Once it's modified, that program will ask V to generate main.so with the modified function and reload foo. So if you change println(1) to println(2) while the program is running, you will get

1
1
2
2

>All comments

Good question. I'll add info about it to the docs.

Let's say you have

#!hot

fn main() {
    for {
        foo()
        time.sleep(1)
    }
}

fn foo() {
    println(1)
}

It will print number 1 every second.

However since we used the hot directive (name is not final 馃槂), foo() is loaded dynamically, and V will insert a small program that will run in the background and wait for modifications in main.v. Once it's modified, that program will ask V to generate main.so with the modified function and reload foo. So if you change println(1) to println(2) while the program is running, you will get

1
1
2
2
Was this page helpful?
0 / 5 - 0 ratings

Related issues

XVilka picture XVilka  路  3Comments

aurora picture aurora  路  3Comments

arg2das picture arg2das  路  3Comments

ArcDrake picture ArcDrake  路  3Comments

PavelVozenilek picture PavelVozenilek  路  3Comments