logoalt Hacker News

artrax • yesterday at 9:18 PM • 0 replies • view on HN

We build this as a c++ library, do to query-compilation for our stream processing engine.

https://github.com/nebulastream/nautilus

It allows us to implement operators or functions without having to write them in terms of LLVM IR DSL (or similar). Rather, you write your functions over a wrapper type (and returning one), for which there is an overload of anything which you can overload in c++.

You can instantiate a wrapper from some c++ value, in which case the wrapper will just forward everything to this value, which was nice for debugging in the preagentic era. But, you can also instantiate such a wrapper as a tracer, and the result of the functions evaluation will be a trace.

For controlflow, we record whenever a wrapper type is evaluated as a bool, first return true, and when we reach the end of one branch, throw an exception to get back to the beginning, and start all over again, but evaluate it to false.

The resulting trace we can turn into LLVM IR and compile, or run for example in wasm