Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Here are some cute preprocessor macros: #define begin { #define end } With these, I can write C code that looks more like Pascal. What do yall think?

0
Posted

Here are some cute preprocessor macros: #define begin { #define end } With these, I can write C code that looks more like Pascal. What do yall think?

0

Use of macros like these, though perhaps superficially attractive, is generally discouraged; in severe cases the practice is called “preprocessor abuse.” There is little to be gained in trying to redefine the syntax of a language to fit your own predilections, or to match some other language. Your predilections are unlikely to be shared by later readers or maintainers of the code, and any simulation of another language is most unlikely to be perfect (so any alleged convenience or utility will probably be outweighed by the nuisance of remembering the imperfections). As a general rule, it’s a good idea if the use of preprocessor macros follows the syntax of the C language. Macros without arguments should look like variables or other identifiers; macros with arguments should look like function calls. Ask yourself: “If I somehow presented this code to the compiler without running it through the preprocessor, how many syntax errors would I get?” (Of course, you’d get plenty of undefined

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123