Talk:Digraphs and trigraphs
|WikiProject Computing||(Rated Start-class)|
I very much doubt that this phrase "replaces all occurrences" is correct (my emphasis). For example, it should not replace occurences of that sequence within strings.
- It is correct.
- Sadly. This is a prime example of design by committee
Is the \? escape really standard, or just typical? Might there be a compiler that maps it to the 0xfe character or similar? AlbertCahalan 04:06, 23 April 2006 (UTC)
Standard. Akihabara 04:21, 29 November 2006 (UTC)
Should something be added about the more notorious uses of trigraphs (i.e. obfuscation)? Amcfreely 04:07, 23 April 2006 (UTC)
When were trigraphs introduced? Do they only apply to ISO C, for instance? Have any other languages adopted them? --188.8.131.52 03:38, 27 November 2006 (UTC)
- They hark back to the very origins of C. The first edition of K & R refers (in the appendix) to the C compiler having been implemented on four computer platforms, and one of them is the IBM 360/370. Well, that compiler had to implement trigraphs because it was processing EBCDIC! I personally used it, and even had to do maintenance on the very C compiler discussed in the book, back in the early 80's, --Eliyahu S Talk 09:52, 7 December 2009 (UTC)
The bit at the bottom on digraphs lists "%:" as a digraph for "#", and "%:%:" as a digraph for "##". Surely the second one is simply two adjacent digraphs?--NeilMitchell 19:55, 16 September 2007 (UTC)
- "A digraph [...] must always represent a full token by itself." # and ## are different tokens. --184.108.40.206 14:03, 3 December 2007 (UTC)
Can they or can't they be used?
This sentence is unclear:
The C grammar does not permit two subsequent ? tokens, so the only places in a C file where two question marks in a row may be used are in multi-character constants, string literals, and comments.
The whole article seems to say that trigraphs are, in fact, interpreted within constants, literals, and comments - which would imply that you cannot use two question marks in a row there (unless you want them to be interpreted as introducing a trigraph). But this sentence says you can use them there.
I'm not sure what the author meant to say, but I suspect that this wasn't it. JayLevitt 13:41, 7 November 2007 (UTC)
- A token is different from a character. In a-=b], there are three tokens: a, -= (two characters but one token), b. But in a=-b, there are four tokens: a, =, -, b], and in "a--b", there is only one token: "a--b" (six characters, indicating a 5-bit (null-ended) array of characters.
- What the sentence is saying is that there is no place in C where a ? token can be immediately followed by another ? token. Inside quotation marks (i.e. multi-character constants or string literals) and inside comments, two subsequent question marks would not be parsed as individual tokens... they would be parsed as part of the string or ignored as part of the comment.
- —ΨΦorg 13:54, 7 November 2007 (UTC)
I don't know Perl, but the Perl section does not seem to deal with di- and trigraph substitution, it's rather more a list of operators. What are those supposed di- and trigraphs replaced with? 220.127.116.11 (talk) 07:01, 27 April 2009 (UTC)
Trigraphs in TeX use a character with category code seven, which is doubled and then followed by one or two additional characters, this is treated as if the corresponding character is found in input. Unlike C, the TeX trigraphs can be very useful sometimes. --zzo38(✉) 04:56, 2 October 2010 (UTC)