in reply to 10 languages

Nice, I'm surprised there was more to add without breaking the rest. I've been looking at Lisp myself, but unfortunately there doesn't seem to be a way to add that without making either the C or the Lisp code invalid, or removing some other language. (C, Lisp, Perl, and maybe sh and TeX is doable though. The big problem is PostScript.)

Update: Yup, C, Lisp, Perl, sh and TeX is possible:

// +'+%#| //\output{\setbox0\vbox{\box255}\setbox0\hbox{\parindent0ptJust anothe +r \TeX\ hacker,}\shipout\box0}\bye #include <stdio.h> int main() { puts("Just another C hacker,"); } /*%|# (princ "Just another Lisp hacker, ") (quit) +'+ 2>&- if print "Just another Perl hacker, " and exit; printf "Just another sh hacker, "; exit #*/

Replies are listed 'Best First'.
Re^2: 10 languages
by Anonymous Monk on Jan 17, 2006 at 17:42 UTC
    If you open a paren in PostScript, it just starts a string, which you can cancel later with `pop'. And a paren is a quite harmless character in most other languages. See the 1st two lines in my original code.
      Thanks. Unfortunately, the problem is that a C program (again, unless you don't mind making it invalid) can't start with a (; it must start with a keyword after preprocessing, and before preprocessing, the only ways around that are by starting with #, %:, //, /*, or _Pragma, possibly combined with \. (Technically, trigraphs could also be used, but ?? causes even bigger problems.) Comments in Lisp start with ; or are embedded in #|...|#, so the opening must be a valid Lisp expression. The two things that don't break C that I could find are //, and #\ followed by a newline. Both seem to unconditionally break PostScript, but if you have a way around that, I'd be very interested.