Independently of the encoding question, we should have another SRFI
that specifies how the Scheme reader handles "#!" directives. I am
thinking of a parameter object bound to a procedure that is called
with the port and the s-exp following the "#!" directive whenever the
reader encounters a "#!" directive. The procedure should be able to
tail-call a success or a failure procedure. On such a SRFI, we can
portably build many reader extensions.This SRFI should also expose a
way to inspect and modify the state of ports (in particular whether
case-folding is enabled, but also being able to access column and row
counters makes sense).
Gauche has a reader hook for #!identifier, though it's not documented yet. Using it, you can
write a source code in different syntax; I've written an M-expression reader so that
you can write code in M-expr, e.g.:
===========================
(use LISP1.5.mexpr)
#!m-expr
mapcar[fn;x] = [null[x] -> NIL;
T -> cons[fn[car[x]];mapcar[fn;cdr[x]]]]
===========================
I assume Racket has something similar, for their #!lang tag. If there'll be a srfi for that
I'll adapt Gauche for that.