Portable Self-Replicating C Contest

David H. Wolfskill david at dhw68k.cts.com
Sun Apr 16 08:25:34 AEST 1989


In article <6756 at bsu-cs.bsu.edu> dhesi at bsu-cs.bsu.edu (Rahul Dhesi) writes:
>In article <12629 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer)
>writes:
>>(One correct fix is to use `printf("?\?=")', but since `\' is itself a
>>trigraphable character, this must be written `printf("???/?=")'!)
>                                                       ^^^^^^
>This seems awfully difficult for a lexical analyzer to handle, and
>perhaps illustrates my point again.  (Isn't ? itself a trigraph
>character, at least when ambiguity requires it?)

No, '?' is *not* representable by a trigraph sequence.  Section 2.2.1.1
("Trigraph Sequences") reads (in the May 13, 1988 draft):

-=-=-=-=-=-=-=-=-=-=-=

All occurrences in a source file of the following sequences of three
characters (called *trigraph sequences*[5]) are replaced with the
corresponding single character.

	??=	#
	??(	[
	??/	\
	??)	]
	??'	^
	??<	{
	??!	|
	??>	}
	??-	~

No other trigraph sequences exist. Each ? that does not begin one of the
trigraphs listed above is not changed.

Example

	The following source line

		printf("Eh???/n");
	
becomes (after replacement of the trigraph sequence ??/)

		printf("Eh?\n");

-----
5. The trigraph sequences enable the input of characters that are not
   defined in the ISO 646-1983 Invariant Code Set, which is a subset of
   the seven-bit ASCII code set.

-=-=-=-=-=-=-=-=-=-=-=

>As a sporting gesture, would you be willing to repost the contest
>rules, this time using trigraphs only in place of the offending
>symbols?  If that doesn't make my point, nothing will.

I think Karl's rules were clear enough.  As to the trigraphs, I don't
know of anyone who claims that they are aesthetically pleasing; some
mechanism, however, needs to exist for representing characters that do
not exist in an environment's character set (unless, of course, X3J11
had been willing to banish folks in such circumstances to a C-less
existence).  To quote Douglas Adams (note "Adams," not "Gwyn") "You
were quite entitled to make any suggestions or protests at the
appropriate time, you know."

david
-- 
David H. Wolfskill
uucp: ...{spsd,zardoz,felix}!dhw68k!david	InterNet: david at dhw68k.cts.com



More information about the Comp.std.c mailing list