[reader syntax] #! interpreter
This line appears as the first line of executable scripts in Unix (sometimes called as "shebang").
SRFI-22 says that if the first line begins with '#!', the line is ignored.
Gauche ignores the line beginning with '#!', up to the end of the line.
MzScheme: ignores the first line beginning with '#!'. If the line ends with '\', then the next line is ignored as well.
[reader syntax] #! identifier
R6RS uses this syntax for directives to the reader. Syntactically it is treated as a comment.
#!r6rs denotes that the stuff following this conforms r6rs syntax without extension. R6RS also mentiones #!fold-case and #!no-fold-case to control reader's case folding mode, although it is not in the spec per se, but in non-normative appendix.
In R6RS, shebang in scripts are treated as a different lexical context (it is not a part of toplevel scheme program, but is a part of <script-header>. See R6RS Appendix D.
Note that this specification requires a reader for Scheme scripts and a reader for other Scheme programs be different. If a file begins with #!<identifier>, there's no way to tell from the content itself that it is a Scheme script or a Scheme program, since Appendix D recommends that implementations should ignore the first line if it begins with #!, even if it is not #!/ or #!<space>. If the reader is a 'script' mode, it ignores anything after #!<identifier> until the end of line. If the reader is in r6rs mode, it should only ignore (or interpret) #!<identifier> token.
'#!<identifier>' syntax has been used in past RnRS (e.g. #!true), and also by several existing implementations (e.g. #!bwp). Since those usages do denote a datum, they can't be used together with R6RS-compatible reader, which would treat those tokens as comments.
The safe bet is to switch the reader mode when it sees #!r6rs token.
A questionable situation is when a reader sees #!r6rs at the beginning of the file. If it is an R6RS Scheme program or library, then the token asserts it is so. If it is a Scheme script, however, the whole first line should be ignored (even if the script is r6rs conformant). In practice such file is very likely to be an R6RS Scheme program (not script), but this uncertainty is somewhat uncomfortable.
Another issue is the scope of '#!<identifier>' directive. Apparently #!r6rs, #!fold-case and #!no-fold-case affects the rest of the stream, possibly until the other directive appears. It means that the state is not local to a read procedure. For loading programs, the loader may keep the state. But what if we want to read the same file as data?
About This Site
Concept:CaseSensitivity Concept:DocumentationFormat Concept:ExtendedLambdaList Concept:FileSystem Concept:FindAndAnyInCollection Concept:HashTable Concept:Module Concept:Networking Concept:ObjectSystem Concept:Process Concept:RegularExpression Concept:UserGroup