+ X-NEWS: spcvxb alt.folklore.computers: 8750 I Relay-Version: VMS News - V6.0 13.10.90 VAX/VMS V5.4; site spcvxb.spc.edu  Path: spcvxb.spc.edu!njin!paul.rutgers.edu!aramis.rutgers.edu!dimacs.rutgers.edu!mips!zaphod.mps.ohio-state.edu!samsung!uunet!munnari.oz.au!metro!news= Newsgroups: rec.puzzles,comp.lang.misc,alt.folklore.computers  Subject: A polyglot program 7 Message-ID: <1991Mar18.131907.11757@metro.ucc.su.OZ.AU> , From: peril@extro.ucc.su.OZ.AU (Peter Lisle) Date: 18 Mar 91 13:19:07 GMT Sender: news@metro.ucc.su.OZ.AU = Organization: Uni Computing Service, Uni of Sydney, Australia % Nntp-Posting-Host: extro.ucc.su.oz.au 	 Lines: 97 M Xref: spcvxb rec.puzzles:3047 comp.lang.misc:2806 alt.folklore.computers:8750   F A little while ago some people were talking about polyglot programs inF rec.puzzles, these are programs that are written in several languages.4 We thought it sounded like fun so we wrote this one.  E Our friends suggested we should post it -- so here it is, let us know  what you think.     E -------- cut here (keep the blank lines: they are important) --------     P                                                                          (*O/*_/N Cu  #%* )pop mark/CuG 4 def/# 2 def%%%%@@P[TX---P\P_SXPY!Ex(mx2ex("SX!Ex4P)Ex=N CuG #%*                                                                  *+Ex=N CuG #%*------------------------------------------------------------------*+Ex=N CuG #%*   POLYGLOT - a program in seven languages      15 February 1991  *+Ex=N CuG #%*                                                                  *+Ex=N CuG #%*   Written by Kevin Bungard, Peter Lisle, and Chris Tham          *+Ex=N CuG #%*                                                                  *+Ex=N CuG #%*   We have successfully run this program using the following:     *+Ex=N CuG #%*     ANSI COBOL:            MicroFocus COBOL85 (not COBOL74)      *+Ex=N CuG #%*     ISO  Pascal:           Turbo Pascal (DOS & Mac), Unix PC,    *+Ex=N CuG #%*                            AIX VS Pascal                         *+Ex=N CuG #%*     ANSI Fortran:          Unix f77, AIX VS Fortran              *+Ex=N CuG #%*     ANSI C (lint free):    Microsoft C, Unix CC, GCC, Turbo C++, *+Ex=N CuG #%*                            Think C (Mac)                         *+Ex=N CuG #%*     PostScript:            GoScript, HP/Adobe cartridge,         *+Ex=N CuG #%*                            Apple LaserWriter                     *+Ex=N CuG #%*     Shell script:          gnu bash, sh (SysV, BSD, MKS), ksh    *+Ex=N CuG #%*     8086 machine language: MS-DOS 2.00, 3.03, 4.01, 5.00 beta    *+Ex=N CuG #%*                            VPix & DOS Merge (under unix)         *+Ex=N CuG #%*                            SoftPC (on a Mac), MKS shell          *+Ex=N CuG #%*                                                                  *+Ex=N CuG #%*   Usage:                                                         *+Ex=N CuG #%*     1. Rename this file to polyglot.[cob|pas|f77|c|ps|sh|com]    *+Ex=N CuG #%*     2. Compile and/or run with appropriate compiler and          *+Ex=N CuG #%*        operating system                                          *+Ex=N CuG #%*                                                                  *+Ex=N CuG #%*   Notes:                                                         *+Ex=N CuG #%*     1. We have attempted to use only standard language features. *+Ex=N CuG #%*        Without the -traditional flag gcc will issue a warning.   *+Ex=N CuG #%*                                                                  *+Ex=N CuG #%*     2. This text is a comment block in all seven languages.      *+Ex=N CuG #%*                                                                  *+Ex=N CuG #%*     3. When run as a .COM file with MS-DOS it makes certain      *+Ex=N CuG #%*        (not unreasonable) assumptions about the contents of      *+Ex=N CuG #%*        the registers.                                            *+Ex=N CuG #%*                                                                  *+Ex=N CuG #%*     4. When transfering from Unix to DOS make sure that a LF     *+Ex=N CuG #%*        is correctly translated into a CR/LF.                     *+Ex=N CuG #%*                                                                  *+Ex=N CuG #%*   Please mail any comments, corrections or additions to          *+Ex=N CuG #%*   peril@extro.ucc.su.oz.au                                       *+Ex=N CuG #%*                                                                  *+Ex=N CuG #%*------------------------------------------------------------------*QuZ=N CuG #%*                                                                  *+Ex=K CuG #%*!Mx)ExQX4ZPZ4SP5n#5X!)Ex+ExPQXH,B+ExP[-9Z-9Z)GA(W@'UTTER_XYZZY'CPK*+ K CuG #(*                                                                  *( K C   # */);                                                              /*( K C   # *)  program        polyglot (output);                             (*+ " C   #     identification division." C   #     program-id.    polyglot. C   # " C   #     data           division." C   #     procedure      division. C   # I C   # * ))cleartomark   /Bookman-Demi findfont 36 scalefont setfont     ( I C   # *                                                                 (  C   # ) C   # *                  hello polyglots$  C   #     main.  C   #         perform 7 C     * ) 2>_$$; echo   "hello polyglots"; rm _$$; exit                print  C             stop run. )      -*,                'hello polyglots'  C  C         print.I C             display   "hello polyglots".                              ( J C     */  int i;                                                        /*J C     */  main () {                                                     /*J C     */      i=printf ("hello polyglots\n"); O= &i; return *O;         /*J C     *)                                                                (*J C     *)  begin                                                         (*J C     *)      writeln  ('hello polyglots');                             (*L C     *)                                                                (* )I C     * ) pop 60 360                                                    ( I C     * ) pop moveto    (hello polyglots) show                          ( J C     * ) pop showpage                                                  (( C     *)M            end                                                          .(* ) N C)pop%     program       polyglot.                                      *){*/}N ------------------------------ cut here --------------------------------------   Have fun...    Peter 