Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
I can write C code that looks more like Pascal? ....
Here are some cute preprocessor macros:
#define begin {
#define end }
With these, I can write C code that looks more like Pascal. What do y'all think?
✍: Guest
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 symbols and non-constant array dimensions, but those aren't syntax errors.) This rule means that C code, plus macro invocations, still looks like C code. So-called nonsyntactic macros like begin and end or CTRL(D)
2016-02-24, 1125👍, 0💬
Popular Posts:
Describe different elements in Static Chart diagrams ? Package: - It logically groups element of a U...
Can Java object be locked down for exclusive use by a given thread? Yes. You can lock an object by p...
What Is a TD Tag/Element? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells A "td" elemen...
If locking is not implemented what issues can occur? IFollowing are the problems that occur if you d...
What Is the "@SuiteClasses" Annotation? "@SuiteClasses" is a class annotation defined in JUnit 4.4 i...