@keskiverto, @helios, @seeplus,
I don't often use weird macros like that loop example. In fact, I haven't used them at all except in a little experiment, mainly because I was trying to figure out what all you could do with them since my CS textbook doesn't cover them much.
@jonnin,
I doubt any serious programmers are dumb enough to do stuff like my loop macro. And if they are, they won't last long. I only used it once, in an experimental program where I was messing around with #define (and getting about 20 errors in the process, so I quit that).
Your previous quote made quite the opposite impression:
Although I also don't use macros a lot, unless I'm redefining loops or something for simplicity
We were reacting to this statement in which you implied you use macros to "simplify" loops quite often. Now you say you don't use them. I know I'm confused.
My 2 cents: Don't use macros or cutesy code. Be as clear as possible
Oops. Ok, a word of advice: When you tell a lie, make sure you stay consistent!
I was trying to, oh, I don't know. Make it seem like I knew a lot about #define and preprocessor macros and all that stuff. I don't actually know a lot about them, and I really don't use them, except in one experimental program.
It was just for fun, really. It looks kind of wonky, and if you don't notice the macros, you'd look at it and go "What in the...? What language is that?"
I seem to remember reading something a few years ago that one of the original Unix/c developers created their own 'basic' like language using macros and developed a major Unix program in this 'language' that looked like basic but was actually c. Does any one remember anything about this or have an internet reference?
not really. you may be able to compile such a beast in the other language, if they did it down to the wire on every detail, but usually there is some little something that was overlooked. case in point, for pascal, I am not even sure if you CAN tell the preprocessor to replace {} with "begin" and "end". you would have to get funky and make begin and end generate unique goto labels or something horrid.
there are legit uses of this kind of thing. a few select macros like this could let you translate across languages quickly, making fewer changes from whatever into c++ by letting the macros do the work. In which case if you write them well, you could then expand the macros back to c++ code and keep that version, and do away with the macros afterwards. I forget how but there is a way to expand them and dump it back to a legit c++ file.
Experimenting is fine. There's lots of existing code that uses macros so if you are expecting to be involved with 'legacy' code then you'll probably need at least a familiarity with macros.