T.R | Title | User | Personal Name | Date | Lines |
---|
115.1 | | HARE::STAN | | Mon Apr 29 1985 20:26 | 9 |
| I did this back in college. It was a program that read in a number, n,
and then read in n numbers and printed out the numbers in sorted order.
It worked correctly whether you fed it to the FORTRAN or the PL/I compiler.
To make the problem harder, I also had the restriction that there
could not be comments in either language and you could not go
past column 72 (since fortran ignores everything past column 72).
I still have the card deck...
|
115.2 | | GOLLY::GILBERT | | Tue Apr 30 1985 07:40 | 8 |
| You must be new here.
I recall that one note had a program that could be compiled in any of three
languages, and would print a copy of itself. Perhaps some reader can supply
the note number of this arcane gem?
Anyway, welcome to HACKERS. If you look back at other notes, you'll discover
many other interesting perversions. Enjoy.
|
115.3 | | BEING::POSTPISCHIL | | Tue Apr 30 1985 09:58 | 14 |
| Re .2:
I saw the self-printing programs (I've seen them before, but I haven't
seen ones as short as were presented here -- that one-line C program is
great!), but I must have missed the three-language version. I definitely want
to see that, if anyone knows where it is.
Well, if it's been done before, let's see how many languages it can
be done for. Can anyone show a self-printing four-language program? Or any
four-language program? I like the restrictions about comments -- can anyone
else offer suggestions for good restrictions?
-- edp
|
115.4 | | BEING::POSTPISCHIL | | Tue Apr 30 1985 10:16 | 7 |
| Re .2, .3:
I found the note with the self-printing programs in it (#95), but I
didn't see anything that worked in more than one language. If anyone knows
where this program is, please let me know.
-- edp
|
115.5 | | VIKING::WASSER_1 | | Tue Apr 30 1985 14:06 | 6 |
| As a side note: Microsoft wrote many of the "include" files
used in a Microsoft Windows environment so that they work
equally well when included in 'C' or MASM programs.
-John Wasser
PCSGSE
|
115.6 | | VAXUUM::DYER | | Wed May 01 1985 00:06 | 26 |
| Note #43 in VAXUUM::SYS$NOTES:LANGUAGES.NOT has the attached gem
in it.
#6 <_Jym_>\
(* 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 */ }
|
115.7 | | TRON::WARWICK | | Wed May 01 1985 04:13 | 5 |
| Re:.6 Works in VAX C but not PASCAL or FORTRAN (even with /nof77/noextend).
Trevor
|
115.8 | | MANANA::COLGATE | | Wed May 01 1985 23:14 | 33 |
| Here is one that should do the trick; However, it does not conform to Stan's
restriction... It uses comments to make it work.
Wim
(* main(
))(){/*
C
C
C Fortran comments.... Note above right...
C
C
100 FORMAT (30H THESE STATEMENTS SATISFY THE )
110 FORMAT (30H FORTRAN COMPILER....... )
WRITE(5,100)
WRITE(5,110)
END
C *) (*
C *) program main(output); (*
C *) begin (*
C *) (*
C *) writeln('This could be a complete pascal program!'); (*
C *) writeln('But why would you want it too be?'); (*
C *) (*
C *) end. (*
C */ /*
C */ printf("This is infact a C program,\n"); /*
C */ printf("But like the above two, it is rather boring.\n"); /*
C */ }
|
115.9 | | HARE::STAN | | Thu May 02 1985 15:00 | 6 |
| So far, these programs cheat: they really contain complete programs
in each language, embedded within comments of the other language.
The challenge is to do it without comments.
Does anyone have a card reader to read in my deck?
|
115.10 | | BEING::POSTPISCHIL | | Thu May 02 1985 19:39 | 13 |
| A card reader -- what's that? I just finished school and they didn't tell me
anything about card readers. Is this some new invention? (Just kidding.)
I like the program shown; I was starting to think everyone was kidding me about
having seen one. But I agree, it would be nicer to do it without comments.
But in case this is too difficult, how about a program in which there are
tokens (words, symbols, et cetera) which are interpreted by the compilers as
non-comments. That is, you could still use comments, but some of the tokens
would have to be used by more than one compiler. Perhaps "begin" could be
a keyword in one language and a variable in another.
-- edp
|
115.11 | | LATOUR::SPIDER | | Sat May 04 1985 00:14 | 3 |
| Re: .9
I don't know if my card reader still works, but I have one.
|
115.12 | | PARVAX::PFAU | | Sat May 04 1985 12:48 | 3 |
| I have a card reader and an interface. Anyone have a cable?
tom_p
|
115.13 | | LSMVAX::BLINN | | Sun Jun 16 1985 21:45 | 7 |
| BTW, the Fortran/PL/I program will probably run through a SNOBOL-4
compiler/interpreter with no diagnostics, but may not run. And of
course, SNOBOL is the language in which a properly written program can
have every statement except the first and last placed in a random order
and have the program still run correctly.
#6[1mTom[0m
|