Re: Syntax of Comments (was: language design tradeoffs)

fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Thu, 24 Sep 1992 18:47:48 GMT

          From comp.compilers

Related articles
[5 earlier articles]
Re: Syntax of Comments (was: language design tradeoffs) jlg@cochiti.lanl.gov (1992-09-23)
Re: Syntax of Comments (was: language design tradeoffs) jimc@tau-ceti.isc-br.com (1992-09-24)
Re: Syntax of Comments (was: language design tradeoffs) crowl@jade.cs.orst.edu (1992-09-24)
Re: Syntax of Comments (was: language design tradeoffs) crowl@jade.cs.orst.edu (1992-09-24)
Re: Syntax of Comments (was: language design tradeoffs) beshers@hks.com (1992-09-24)
Re: Syntax of Comments (was: language design tradeoffs) macrakis@osf.org (1992-09-24)
Re: Syntax of Comments (was: language design tradeoffs) fjh@munta.cs.mu.OZ.AU (1992-09-24)
Re: Syntax of Comments (was: language design tradeoffs) delacour@parc.xerox.com (Vincent Delacour) (1992-09-24)
Re: Syntax of Comments (was: language design tradeoffs) macrakis@osf.org (1992-09-25)
Re: Syntax of Comments (was: language design tradeoffs) de19@umail.umd.edu (1992-10-04)
Re: Syntax of Comments (was: language design tradeoffs) Bruce.Hoult@bbs.actrix.gen.nz (1992-10-05)
Re: Syntax of Comments (was: language design tradeoffs) tmb@arolla.idiap.ch (1992-10-06)
Re: Syntax of Comments (was: language design tradeoffs) liblit@cs.psu.edu (1992-10-06)
[3 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers,comp.human-factors
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Organization: Computer Science, University of Melbourne, Australia
Date: Thu, 24 Sep 1992 18:47:48 GMT
References: 92-09-048 92-09-157
Keywords: C, parse, syntax

jimc@tau-ceti.isc-br.com (Jim Cathey) writes:


>I for one appreciate the hell out of cpp, because it allows me to maintain
>_one_ source for many slightly different environments. ...
>If this sort of preprocessor mechanism were not already present in C I
>would have had to write one anyway (or use m4?), or face a maintenence
>nightmare. I submit that cpp's presence is one of the reasons that C is
>so strong in the industry.


This is a very good point. How many of the languages that were competing
with C came complete with a macro pre-processor as standard? I think that
you are right in suggesting that cpp is one of the major reasons for C's
success.


>It's a tool that wears well, though, like any tool, it can be abused.


The moderator replies:


>[Many in the C++ crowd claim that "const" declarations in combination with
>in-line functions and sensible optimization of "if" statements that depend on
>constants give you nearly everything CPP does without the aggravation of C's
>two-level syntax. -John]


Unfortunately, "nearly" is the operative word.


#ifdef's are usually used at file scope, rather than in places where a
statement could occur. They often surround code whose very syntax may be
compiler-specific, so the two-level structure is *necessary*, to prevent a
compiler from attempting to parse code it could not possibly understand.


Typical examples such as


#ifdef __GNUC__
#define no_return volatile void
#define no_side_effects const
#else
#define no_return void
#endif
...
INLINE int foo(void) { ... }


#ifdef __TURBOC__
#pragma such-and-such
#endif


#if __GNUC__
#define PLACEMENT_NEW(expression) new { expression }
#else
#define PLACEMENT_NEW(expression) new ( expression )
#endif
... var = PLACEMENT_NEW(address) Type;


are still very common, and I do NOT expect cpp to go away, at least not for
a long while yet.


--
Fergus Henderson fjh@munta.cs.mu.OZ.AU
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.