I've been inclined to write "source code encoding magic comment" srfi, which Gauche is using.  If there's a comment
that matches a specific pattern at the beginning of the source, it can specify the file encoding.

Without it, using non-ascii characters in the source code may cause a portability issue.




On Sun, May 12, 2019 at 12:19 AM Lassi Kortela <xxxxxx@lassi.io> wrote:
Has there been discussion of permitting Unicode lambda in Scheme source
code? I use it in Racket and I find that it makes code easier to read
since 'lambda' is quite a long identifier for something you write all
over the place. It's especially nice for making two-line lambdas fit in
one line of code.

I tried this simple macro definition:

(define-syntax λ
   (syntax-rules ()
     ((_ rest ...)
      (lambda rest ...))))

And these tests:

((λ (x) (+ x 1)) 1)  ; => 2

(apply (λ xs (list xs)) 1 2 '(3 4 5))  ; => ((1 2 3 4 5))

Those work out of the box in Chez, Chibi, Chicken, Gauche and Kawa with
the default settings of those Schemes in a UTF-8 Unix terminal.

Unicode lambda is also the same single codepoint under all Unicode
normalization forms, so no aliasing problems there.

(Fun fact: if you type λ in Emacs and then press M-u to uppercase it, it
turns into Λ logically enough.)

I wonder if there's any Scheme implementation that does case folding so
you could use (Λ (x) x) as an alias for (λ (x) x). I would find it
hilarious, but I don't know if it's appropriate for mass consumption.
Most Schemes default to case-sensitive nowadays
(<http://practical-scheme.net/wiliki/schemexref.cgi?Concept%3ACaseSensitivity>).
At least Gauche's `gosh -fcase-fold` mode treats lowercase and uppercase
lambda as separate characters.

Apart from the above, source file encoding raises some concerns. I can't
find any mention in R6RS or R7RS that source code has to be UTF-8 or
Unicode in general. FWIW, the Go language mandates UTF-8. Obviously we
can't change R6RS and R7RS-small (and perhaps not even R7RS-large) to
require UTF-8 at this stage, but if there's a Unicode-lambda SRFI then
that SRFI could perhaps make such a demand for files that import it.

There are also various hacks to render the word "lambda" as the Greek
letter in Emacs: <https://www.emacswiki.org/emacs/PrettyLambda>.
Nowadays it's as simple as doing M-x prettify-symbols-mode. I don't know
if there are unintended side effects to this - I can imagine that in
some situations you'd want to keep some symbols as 'lambda' and only
have our beloved abstraction operator use the Greek letter. For example,
prettify-symbols-mode renders (lambda 'lambda lambda 'lambda lambda) as
a list of five Greek lambdas.