About optimizations

Because Dialog’s debugger can evaluate queries, there’s less of a need to provide not-for-release commands. You can get by with just a query, like the (tree) I posted about recently.

How smart is Dialog’s compiler? If a rule is defined by there’s never an query against it, is anything emitted to the compiled zcode?

1 Like

You can generally trust the compiler to be smart about eliminating unreachable code, text strings, and dictionary words. In other words, it should be safe to include (tree) in the source code, and only use it from the debugger.

If you are unsure, add some unique text to the rule body, and then run the compiled game through txd (z-tools) or aamshow (Å-machine tools) to verify that the text isn’t there.

I realized just now that there’s a flaw in the current version of the algorithm: Closures are always considered reachable, even if they are defined inside an unreachable block of code. By extension, every predicate that is queried from inside a closure is also considered reachable. In the long run, this flaw should be fixed, but I don’t think it’s a huge problem in practice.