Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 9/27/83; site hplabs.UUCP Path: utzoo!linus!decvax!hplabs!davis From: davis@hplabs.UUCP (Jim Davis) Newsgroups: net.lang.c Subject: Re: Is it C or is it Pascal? Message-ID: <1049@hplabs.UUCP> Date: Sat, 3-Nov-84 06:19:42 EST Article-I.D.: hplabs.1049 Posted: Sat Nov 3 06:19:42 1984 Date-Received: Sun, 4-Nov-84 04:49:25 EST References: <375@tjalk.UUCP> Organization: Hewlett Packard Labs, Palo Alto CA Lines: 56 > From: sjoerd@tjalk.UUCP (Sjoerd Mullender) > Newsgroups: net.lang.c > Subject: Is it C or is it Pascal? > Message-ID: <375@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@csnet-relay ------------------------------------------------------------------