Skip to main content
gamedev.net
🔒 Locked

c++ style defines in python

Started by denethor Mar 8, 2003 at 11:12 PM 11 replies 1k views
Original Post
denethor
denethor
Is there anyway make a c++ style define in python? Or somthing that just mimicks it? [edited by - denethor on March 8, 2003 12:13:31 AM]
Arild Fines
Arild Fines
Why would you commit such an atrocity in Python?

Or in C++, for that matter?



"If there is a God, he is a malign thug."
-- Mark Twain
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
denethor
denethor
Hmmm. Do you know what a define is? Do you know C/C++?

Almost every C/C++ program known to mankind makes use of defines. Could they really be that bad?



[edited by - denethor on March 9, 2003 10:50:36 AM]
Arild Fines
Arild Fines
quote:
Original post by denethor
Hmmm. Do you know what a define is?


Yes.
quote:

Do you know C/C++?


Yes.
quote:

Could they really be that bad?


Yes.



"If there is a God, he is a malign thug."
-- Mark Twain
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
FearedPixel
FearedPixel
hmm, well define''s aren''t type safe ... although theyre not really that bad. it can be usefull, since it is processed by the pre-processor, and not at runtime -> therefor it could possibly be more efficient. (a variable isn''t created in memory to store the value, but rather, references to the constant are replaced within the actual source code).

That is, if you are talking about that specific use of define. of course there are many other uses for define, which can be certainly very useful. (ie debugging etc...)
denethor
denethor
Sure, defines are not type safe. They are a quick and dirty way to get the job done. But, do you put on a seat belt when you are only driving 2 blocks? Do you stay inside so you will not get skin cancer?

Arild Fines, you must not have must experience with professional development. The largest corporations are using defines in their code! What does that tell you? (Alright, no Microsfot jokes today...)

[edited by - denethor on March 9, 2003 1:16:42 PM]
Alpha_ProgDes
Alpha_ProgDes
why does everyone assume that because someone say something out of the norm they are not in professional s/w development?

believe me even if Arlid isn''t in "pro s/w dev" he is certainly more than qualified to give professional advice and insight.

instead of insulting him, why not just ask why he disagrees with the idea/question?


500
Beginner in Game Development?  Read here. And read here.  
denethor
denethor
I am not insulting him. As a matter fact, he is the one who said
"Why would you commit such an atrocity," which was a worthless comment that did nothing to answere my question, but rather was an expression of his biased opinion.
Flarelocke
Flarelocke
Well, it depends on how well you want it to mimick a variable.

I think the closest you can get is just assigning a global variable.

There may be a way to ensure that it is not an lvalue (i.e. it cannot be assigned to), but I don''t know how. When psyco matures, it won''t make a difference, either. (the variable having the same value throughout the program will have the same effect on efficiency as in a C program)
---New infokeeps brain running;must gas up!
denethor
denethor
I am really looking for the replacement of text. So I can put "x" and have it replaced by "xyz" at runtime. Not the variable aspect. But it doens't seem there is a way to do that in py, unless i program it myself.

[edited by - denethor on March 9, 2003 1:35:19 PM]
SiCrane
SiCrane
Depending how you''re using Python, you might be able to run the source through sed before passing it to your Python program.
Qw3r7yU10p!
Qw3r7yU10p!
quote:
Original post by denethor
I am really looking for the replacement of text. So I can put "x" and have it replaced by "xyz" at runtime. Not the variable aspect. But it doens''t seem there is a way to do that in py, unless i program it myself.



why would you want to do that? really, i''m interested...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.