[Oberon] Conditional compilation using IF const THEN

Paul Reed paulreed at paddedcell.com
Sun Aug 12 14:57:20 CEST 2018

Hi Joerg,

> If I limit myself to something like

I didn't read further than that.  ;-)

But seriously:

> CONST debug = TRUE;
> ...
> IF debug THEN Out.String("entry: "); Out.Ln(superDuper, 8); Out.Ln END;
> Why not do it? During test phase "debug = TRUE". For customer shipment
> "debug = FALSE"
> So, it's not really a different code I ship to customers and debug.

Yes it is, if the debug code is optimised out!

But to take Andreas' example of using module Out for this, just replace
the (dynamically-loaded) Out module with a stub version in production.

I know the *system* is not the same, but at least your compiled code is. 
The overhead of the empty call and return is pretty low, at least in a
non-cached system. :)

When I've been bitten by this Debug/Release issue before with commercial
tools, of course even the compiled code is different in Release (complier
optimisation options, which "make the code more difficult to debug" [!],
are typically turned off in Debug).

I'm reminded of another quote, I'm not sure where from, which goes along
the lines that since debugging is far more difficult than writing code,
you'd better not write code at the limits of your intellect. ;-)


More information about the Oberon mailing list