After pulling in 510eae80bf3b92c7e210817c329e4b417d0012ec:
Transpiling the program below I get:
csample.cpp2(49,5): error: local variable 'start' is not used; consider changing its name to '_' to make it explicitly anonymous, or removing it entirely if its side effects are not needed
csample.cpp2(48,5): error: local variable 'counter' is not used; consider changing its name to '_' to make it explicitly anonymous, or removing it entirely if its side effects are not needed
The program uses some other libraries, so you cannot reproduce it, but the bug is obvious: start and counter are used. This program worked before the 510eae80bf3b92c7e210817c329e4b417d0012ec update.
main: () = {
using namespace ::ext;
using namespace ::qtgl;
using namespace ::std;
using namespace ::std::chrono;
device := random_device();
engine := mt19937(device());
dist := uniform_real_distribution(0.0, 1.0);
gen := :() (dist&$*)(engine&$*);
numSpheres : = 25;
spheres := vector<tuple<Coord, double, Color, Coord>>();
resetSpheres := :() = {
if numSpheres&$* != spheres&$*.ssize() {
spheres&$*.clear();
i := 0;
while i < (numSpheres&$*) next i++ {
center := Coord(gen$(), gen$(), gen$());
radius := gen$() / 10.0;
color := Color();
color.setRgbF(gen$(), gen$(), gen$());
dir := Coord(gen$() - 0.5, gen$() - 0.5, gen$() - 0.5);
_ = spheres&$*.emplace_back(center, radius, color, dir);
}
}
};
resetSpheres();
velocity := 0.01;
run(: (inout win: MainWindow) = {
win.setWindowTitle("Concurrent Sample");
win.setDrawBounds(true);
csample := win.menuBar()*.addMenu("CSample");
numSpheresPtr := numSpheres&$;
resetSpheres2 := resetSpheres$;
ns := :vector<int> = (1, 5, 10, 20, 50, 100, 200, 500, 1000);
for ns do (n) {
action := csample*.addAction(QString::number(n));
MainWindow::connect(action, QAction::triggered&, :() = {
numSpheresPtr$* = n$;
resetSpheres2$();
});
}
},
: (inout win: CMainWindow) = {
48: counter := 0;
49: start := system_clock::now();
while true {
coordRadiusColors := vector<CoordDoubleColor>();
s := 0;
while s < (numSpheres&$*) next s++ {
sphere := spheres&$*[s];
center := get<0>(sphere);
radius := get<1>(sphere);
color := get<2>(sphere);
dir := get<3>(sphere);
for Coord::indices() do (ind) {
center[ind] += velocity$ * dir[ind];
if center[ind] < 0.0 || center[ind] > 1.0 {
dir[ind] *= -1.0;
}
}
spheres&$*[s] = (center, radius, color, dir);
_ = coordRadiusColors.emplace_back(center, radius, color);
}
sync(win&, :() = {
win&$*.clear();
win&$*.drawSpheres(coordRadiusColors$);
});
win.redraw();
win.showStatus("(numSpheres&$*)$ spheres");
counter += numSpheres&$*;
if counter > 10000 {
now := system_clock::now();
println("Spheres per second: (counter * 1000 / duration_cast<milliseconds>(now - start).count())$");
counter = 0;
start = now;
}
}
});
}
After pulling in 510eae80bf3b92c7e210817c329e4b417d0012ec:
Transpiling the program below I get:
The program uses some other libraries, so you cannot reproduce it, but the bug is obvious: start and counter are used. This program worked before the 510eae80bf3b92c7e210817c329e4b417d0012ec update.