[Oberon] Conditional compilation using IF const THEN
Chris Burrows
chris at cfbsoftware.com
Sun Aug 12 14:48:39 CEST 2018
> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Andreas Pirklbauer
> Sent: Sunday, 12 August 2018 9:30 PM
> To: ETH Oberon and related systems
> Subject: [Oberon] Conditional compilation using IF const THEN
>
> And if I really wanted to implement *conditional compilation*, I
> would not use the IF language construct for that, but something else,
> e.g. a compiler directive #IF or something. Not great either IMHO.
> And of course not common at all in Wirthian compilers, to say the
> least..
>
Thank you (and everybody else who has replied) for making me reconsider.
I have always had mixed feelings about conditional compilation. Maybe there's a better way but I haven't seen it yet. If two modules are 95% different then it is easier just to have two separate copies. If they are 5% different, compiler directives are tolerable. It is when they are 50% different and the differences are scattered throughout the file that directives become intolerable and really get in the way of reading code.
1. I could never see the point of disguising compiler directives as special comments e.g. (*$IFDEF*). If it is to prevent compiler errors when compiled on a system which didn't recognise the directive then that would be no use.
2. 'IF cond THEN' blends in with the code a lot better. However, it might be too easy to miss the fact that it is a conditional compilation.
3. 'IF cond THEN' doesn't help if CONST, TYPE and VAR declarations also need to be conditional.
I might just stick with the 'search paths' technique for multiple targets after all
Regards,
Chris
More information about the Oberon
mailing list