[racket] eginner's question on elementary textual replacement...

From: Thomas Chust (chust at web.de)
Date: Fri Mar 9 05:41:44 EST 2012

On Fri, 2012-03-09 at 05:16 -0500, Neil Van Dyke wrote:
> [...]
> CPP macros can cause many kinds of grievous syntactic breakage and
> surprising bugs, and so all-caps as a warning is a great idea; Java
> constants, on the other hand, are one of the safest constructs.
> [...]


although slightly off-topic, I would like to comment on that statement:

Java constants are often declared static final which makes the compiler
inline them in code that uses them, just like constants defined as CPP
macros are compiled into code that uses them. This, of course, causes
breakage if code is relinked against a library version with different
constant values but not recompiled, just like it would for CPP macros.

Since this scenario is relatively common for both languages, I would
disagree that Java constants are much safer and cleaner than CPP macros
used as constants.


When C++ is your hammer, every problem looks like your thumb.

Posted on the users mailing list.