home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!bnr.co.uk!uknet!pavo.csi.cam.ac.uk!ag129
- From: ag129@cus.cam.ac.uk (Alasdair Grant)
- Newsgroups: comp.lang.c
- Subject: Re: Questions about token merging and trigraphs
- Message-ID: <1993Jan5.130133.16398@infodev.cam.ac.uk>
- Date: 5 Jan 93 13:01:33 GMT
- References: <1992Dec19.4396.29938@dosgate> <1992Dec21.172815.18921@thunder.mcrcim.mcgill.edu>
- Sender: news@infodev.cam.ac.uk (USENET news)
- Organization: U of Cambridge, England
- Lines: 50
- Nntp-Posting-Host: bootes.cus.cam.ac.uk
-
- In article <1992Dec21.172815.18921@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
- >In spite of the (apparent) fact that *nobody* uses them? I have yet to
- >see even *one* posting, even from .nl or .be or anywhere else that one
- >might expect to see trigraphs in use, that actually supports them. No,
- >I still stand by my position that trigraphs are a stupid and
- >unsuccessful attempt to solve a nevertheless very real problem.
-
- I use them all the time. As some people have already pointed out,
- the problem is not so much local (although it is true that my keyboard
- lacks square brackets and circumflex) but global. For some character
- sets there are no universally accepted rules for translating into ASCII;
- this means that different compilers can behave in different ways.
- For example, one compiler on my machine reads the character X'5F' as
- the exclusive-OR operator; another reads it as the ones-complement
- operator. (It is the character known as "NOT sign", which usually
- maps on to ASCII circumflex, but since we have a local code for that,
- we map NOT on to ASCII tilde.)
-
- Another one is vertical bar; many character (including ISO Latin 1) have
- both solid and broken varieties. Imagine someone who had followed K&R2
- and used broken bar, only to discover that their compiler writer had
- followed the C standard (ANSI printing, at least) and used the solid bar!
- Yet the ANSI standard is sufficiently informal that both compilers are
- standard-conforming. (Unless you interpret the standard to say that all
- C source code must appear in 10-point Courier bold, as it does in the
- standard. Seriously, I wouldn't want to deny Braille users a conforming
- C compiler.)
-
- I sympathise with people who are worried about lexer overheads, though
- any compiler writer is at liberty to implement a #pragma notrigraphs.
- It's too late for a #pragma trigraphs since there are enough compilers
- around who will accept trigraphs anyway. The point about making trigraphs
- part of the standard is so that I can not only ship my source code to
- other similar systems, I can also run it under gcc on Unix and Microsoft
- C on my PC as well.
-
- All examples of code breakage I have seen are bad style to start with;
- e.g. I'd write der Mouse's example of "?+??=??/" etc. as
- "?" /* 0: reserved */
- "+" /* 1: */
- etc. using ANSI string concatenation. I'd put large pieces of text into
- a help file or message repository. I'd read "tags" from a config. file.
- (Not that I have much confidence in "tags" anyway - the program that
- somebody had that used the string "??(" as a marker in files might have
- problems when faced with ANSI C source code, or indeed with all the old
- K&R source code that we are assured also contains "??(".)
-
- So hooray for trigraphs. And hooray for vendors like Microsoft who
- support them without making a fuss or putting snide comments in their
- documentation.
-