I've recently been thinking about getting languages to talk to each other, mostly in the context of the LISP family, and have been struck by how difficult it is to give clear, language independent, information in a program text about what language you are writing in, and what coding conventions you are using. I've thought of a simple device to correct this, a "dialect" directive, that could easily be integrated into any programming language. Here are a few examples to illustrate what I am talking about:
#dialect C gnu-cpp linux-style
dialect python lexical-scope indent-4-spaces
For the LISP family:
case-sensitive-ids scheme48-package multiline-comments)
* @dialect java sun-codeconv gcj-code
I think having a reasonably coherent, cross-language, machine readable set of conventions for indicating the dialect of a source text is useful, particularly for allowing syntax-directed editors to reliably determine how to format program text, and to figure what identifiers are introduced and how they are used.
An issue is: should dialect directives extend the language? My opinion is they should, since they could be used to influence the semantics of the program, but they should be permitted to occur in comments, so ensuring backwards compatibility.
Another issue concerns UNIX #! directives; see SRFI 22: Running Scheme Scripts on Unix for some discussion of important issues here.
I'd like to write an advogato article about this, probably in a couple of weeks time, but I have to hammer down a few ideas first. In the meantime I am interested in any comments or references to similar ideas.