🔒 Locked
c++ style defines in python
Advertisement
Original Post
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
Or in C++, for that matter?
"If there is a God, he is a malign thug."
-- Mark Twain
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
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...)
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...)
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]
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]
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
believe me even if Arlid isn''t in "pro s/w dev"
instead of insulting him, why not just ask why he disagrees with the idea/question?
500
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)
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)
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.
Advertisement