Is it C or is it Pascal?

Jim Davis davis at hplabs.UUCP
Sat Nov 3 21:19:42 AEST 1984


>	From: sjoerd at tjalk.UUCP (Sjoerd Mullender)
>	Newsgroups: net.lang.c
>	Subject: Is it C or is it Pascal?
>	Message-ID: <375 at tjalk.UUCP>

    While we are on the subject of Ambigous programs
I might add that a humorous (Paul Gootherts & I thought)
article entitled "Common Programming Language Ambiguity"
was published in SIGPLAN February 1981 (?) by
James W Davis, and Paul D Gootherts.

    It is easy to show that -- given either a Pascal
compiler that ignores material after end., or a C or
Pascal compiler that ignores unterminated comments --
any collection consisting of a FORTRAN program, a Pascal
Program, and a C program can be combined into one source
file that will compile correctly in each language.
The programs must satisfy some restrictions (e.g. no
pascal or C identifiers >75 chars in length,
no strings containing another language's close comment
symbol, the rest left to the interested reader).

Below I enclose Sjoerd Mullender & Robbert van Renesse's
program made 4 lingual in the style of the article in SIGPLAN.
Note: the first two lines are not in error, they are indented
to column 73.

									(* main(
									))(){/*
C       Note that we are now in comment mode in Pascal, C, and FORTRAN
C	If we wish, we may insert any FORTRAN here ( e.g.
	DO 10 I=1,0
	    WRITE(6,6)
6	FORMAT (42HTHIS WAS COMPILED BY A FORTRAN 66 COMPILER    )
	STOP
10	CONTINUE
	WRITE(6,7)
7	FORMAT (42HTHIS WAS COMPILED BY A FORTRAN 77 COMPILER    )
	STOP
	END
C *)	(* Note that we may place Pascal source here *)
C *)	program main(output);						 (*
C *)	begin								 (*
C *)	writeln('A Pascal compiler compiled me')			 (*
C *)	end.								 (*
C */	/* Note that we may place C source here */			 /*
C */	printf("A C compiler compiled me\n");				 /*
C */	return (int ( * )()) 0;						 /*
C */	}


-- 
					 Jim Davis (James W Davis)
				{any_of_the_biggies} !hplabs!davis
					  davis%hp-labs at csnet-relay
------------------------------------------------------------------



More information about the Comp.lang.c mailing list