#define in Java

Cameron Laird claird at starbase.neosoft.com
Thu Aug 15 12:11:15 EDT 2002


In article <ajgga3$oa6$1 at slb7.atl.mindspring.net>,
Matt Gerrans <mgerrans at mindspring.com> wrote:
>> 1. #define is not a variable, it's a preprocessor directive.
>
>I think he really meant "How can I have a #defined variable in Java that
>works like C/C++?"
>
>> 2. comp.lang.python is not an appropriate forum in which to ask this
>> question.
>
>Actually, maybe it is; since Java doesn't have preprocessing, if you wanted
>to add it, using Python might be the easiest way.  However, the fact that
!

Easier'n using the C/C++ preprocessor itself?

I suspect the original questioner does not realize that
essentially all C/C++ compilers expose their preproces-
sors (even if it's only under duress, for some of them).
Therefore, in the absence of a more refined specification
from the original questioner, and with full awareness of
my own fondness for Python, my answer would be, if you
want #define-like behavior, use a C preprocessor.
			.
		[lots of true and
		even helpful stuff]
			.
			.
>If you are trying to avoid runtime checks (such as a platform-specific
>behavior), because they supposedly hurt performance, then I would do the
>following: get the code working with runtime checks, then do some profiling
>and discover that these checks really don't affect performance at all.  Then
>you are finished ahead of schedule.
>
>

This part was so true, helpful, and persistently unappre-
ciated I couldn't pass up the chance to repeat it.
-- 

Cameron Laird <Cameron at Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



More information about the Python-list mailing list