I’m wondering if there’s a way to completely remove sections of debug/analytics code via some switch, similar to #define
in C. Currently I’m just doing this.
function f(x, analyse=false)
# compute output
if analyse
# compute rarely-needed expensive statistics
end
end
This is OK, but it would be nice to tell the compiler to just ignore this code when compiling for production. I believe the answer is metaprogramming, which can go deeper than I’m willing to dive, but I suspect the solution here is relatively simple.
I found a couple of related threads on stack overflow etc., but nothing that quite matches.