Why are character arrays special (e

Henry Spencer henry at utzoo.uucp
Wed Feb 15 02:19:06 AEST 1989


In article <1875 at dataio.Data-IO.COM> bright at dataio.Data-IO.COM (Walter Bright) writes:
>The trouble with trigraphs is that they, along with the 'phases of
>translation' rules, require an extra test for each character of source...
>The reason this is a problem is because most of the time spent in a
>compiler is in the reading of source text and splitting it into tokens...

A compiler that spends most of its time tokenizing source obviously isn't
working very hard at code generation.  An optimizing compiler, or even a
non-pessimizing compiler, is not going to be tokenizing-bound, unless
there's been a remarkable leap of compiler technology while I wasn't
watching.  Also:

>...(yes, I use profilers).... I'm well aware of the rule that 90% of the
>execution time is spent in 10% of the code. This is true, however, of
>programs BEFORE profiling and fixing of that 10% occurs. Things flatten
>out a lot after that.

How thoroughly flattened is your compiler?

>... I've found in my compiler (Zortech) that ONE extra
>instruction executed per char read slows down the compiler by 5 to 10%.

Hmm, that's 10-20 instructions per character, with C typically about
20 chars/line, and with even a decidedly slow machine delivering an
instruction per microsecond, gives us 2500+ lines/second.  Is your
compiler really that fast?  I'm surprised.

>It's irritating to have to implement a feature that nobody in their right
>mind is going to use, and that has such a negative impact on the product...

If it's that big a deal, have you considered having a default "no trigraphs"
mode and a slower "trigraphs" mode?  That way, if nobody uses it, there's
no impact except for a bit of code that never gets executed.
-- 
The Earth is our mother;       |     Henry Spencer at U of Toronto Zoology
our nine months are up.        | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list