Then we can do (define g (lambda (x) (let loop ((s 0) (i 0)) (if (eq? i x) s (loop (+ s i) (+ i 1))))))
And compare, ,time (g 10000000) $3 = 49999995000000 ;; 0.293595s real time, 0.290550s run time. 0.000000s spent in GC.
scheme@(guile-user)> ,time (f 10000000) $4 = 49999995000000 ;; 0.158049s real time, 0.150505s run time. 0.000000s spent in GC
So it starts to live in some sense.
Now I consider the compile-rtl code as a research code e.g. it can compile correctly but it's a bit of a hack to churn in the rtl functionality
in the old compile-glil code. It seems to work and I have made enough tooling so that the changes are clean in some sense at the higher level. On the lower level I rest on fluids and hacks with set! to achieve what I need. Anyway the abstractions are powerful enough so that I could build
several compilation strategies and mix between them, for example we could have a native startegy and vm strategy that is more optimized if we have a vm or is running native. There are a few more options as well.
The idea I have is that I would like to have a fairly complete picture of how to compile to the current RTL VM and not introduce too large deviations from wingo's strategy. But instead make it work and build explore from that base. Again having something that run's before trying to tweak is a good strategy I would say.