From 7221865400088780658
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,fbc32fc9914fa748
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2000-12-12 06:41:02 PST
Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!newsfeeds.belnet.be!news.belnet.be!btnet-peer1!btnet-peer0!btnet!dispose.news.demon.net!demon!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: James.Kanze@dresdner-bank.com
Newsgroups: comp.std.c++
Subject: Re: Preprocessor directive and newline
Date: Tue, 12 Dec 2000 14:40:17 GMT
Organization: Deja.com - Before you buy.
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <912ke2$6lc$1@nnrp1.deja.com>
References: <90onv1$dci$1@front7.grolier.fr> <3A30F130.96B9A9D6@student.uni-kl.de>
X-Trace: mail2news.demon.co.uk 976632048 mail2news:9760 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Article-Creation-Date: Mon Dec 11 13:22:15 2000 GMT
X-Http-User-Agent: Mozilla/4.72 [en] (WinNT; I)
X-Http-Proxy: 1.0 x53.deja.com:80 (Squid/1.1.22) for client 193.194.7.77
X-MyDeja-Info: XMYDJUIDkanze
Lines: 60
Xref: supernews.google.com comp.std.c++:2877

In article <3A30F130.96B9A9D6@student.uni-kl.de>,
  strieder@student.uni-kl.de wrote:
> "Fran=E7ois-Xavier Callewaert" wrote:

> > Why does the standard C++ require that a preprocessor directive be
> > the only "thing" on a line(16.1) ?

> >  I can readily understand why it should be the last "thing" on a
> > line, but why should it also be the first ?

> >  Appart from the fact that the following line of code is probably
> > harder to read then the legal alternative is it somehow bad ?

> cout<<"#define BAR"<<endl;

> The preprocessor would have to first scan the line completely to
> recognize whether and where a preprocessor directive starts. Here
> there is none, but a string constant that would have to be
> recognized at first.

It has to do this anyway, at least according to the standard.  The
first thing the preprocessor does is break the line down into
preprocessor tokens, and string literals are preprocessor tokens.

> With the current rule it can decide by the first non-whitespace of a
> line, if there is a preprocessor directive or not. Preprocessing
> directives are removed during preprocessing, this is very easy to do
> with the current rules.

> The lexical analysis would become remarkably more complex if the
> rules allowed appending directives to other lines of code, since
> alle lines would have to be fully scanned to find all
> directives. This slows the preprocessor down.

> So nobody really wants it. It's quite unreadable for programmers, it
> adds complexity to the preprocessor, and it slows it down.

I'm not sure that it would really add that much complexity to the
preprocessor.  Given that preprocessing directives are scanned using
slightly different rules than the rest of the program, and that they
can significantly modify the meaning of the rest of the program,
however, this is one extension that I definitly don't want to see.

--
James Kanze                               mailto:kanze@gabi-soft.de
Conseils en informatique orient�e objet/
                   Beratung in objektorientierter Datenverarbeitung
Ziegelh�ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]



