[r6rs-discuss] [Formal] Scheme should not be changed to be case sensitive.
On Nov 14, 2006, at 10:23 AM, Per Bothner wrote:
> Arthur A.Gleckler wrote:
>> In <3.2. Lexical syntax>: Scheme should not be case sensitive.
>> After thirty years, what new argument came up to justify this change?
>
> One is compatibility with XML: anyone who want to use Scheme symbols
> to represent XML element and attribute names will want case-sensitive
> names. (Of course mapping namespace-aware XML to Scheme symbols is
> trickier. One solution is to support some version of two-level names,
> as Common Lisp does. Kawa does a variant of this.)
>
> Another reason is is to bind to named "things" in case-sensitive
> languages. I.e. a "foreign function interface". For example I
> might want to call a method in Java, C#, or C++, all of which
> are case-sensitive.
Both of those can be solved by providing a case-sensitive means of
interning symbols that contain mixed case. Some implementations
already have this, and it's trivial to implement. Once a symbol is
interned, it can be distinguished from other symbols. The invariant
I'm interested in preserving is that two symbols that differ only in
case will, unless the programmer does something to ensure otherwise,
intern to the same symbol.
>> Does this mean that (eq? 'symbol 'SYMBOL) ==> #f ?
>
> Yes - that is the whole point.
Of course. I was just checking to make sure that I understood. This
change was added to the report with no rationale paragraph or any
other explanation. It will require changing a lot of existing code.
Adding a syntax for interning case-sensitively, e.g. something like #|
MixedCase|, and perhaps changing string->symbol to preserve case,
should be enough to make the XML and foreign-function-interface uses
you mention easy and convenient to implement without requiring a
large change to Scheme.
Also, here's an example of the upper-case convention from MIT Scheme
sources ("runtime/genio.scm"):
(define-syntax define-name-map
(sc-macro-transformer
(lambda (form environment)
environment
(if (syntax-match? '(SYMBOL) (cdr form))
(let ((sing (cadr form)))
(let ((plur (symbol sing 'S))
(proc (symbol 'DEFINE- sing)))
(let ((rev (symbol plur '-REVERSE))
(aliases (symbol sing '-ALIASES))
(aproc (symbol proc '-ALIAS)))
`(BEGIN
(DEFINE ,plur '())
(DEFINE ,rev)
(DEFINE ,aliases '())
(DEFINE (,proc NAME ,sing)
(SET! ,plur (CONS (CONS NAME ,sing) ,plur))
NAME)
(DEFINE (,(symbol proc '/POST-BOOT) NAME ,sing)
(LET ((OLD (HASH-TABLE/GET ,plur NAME #F)))
(IF OLD
(HASH-TABLE/REMOVE! ,rev OLD)))
(HASH-TABLE/PUT! ,plur NAME ,sing)
(HASH-TABLE/PUT! ,rev ,sing NAME))
(DEFINE (,aproc NAME ALIAS)
(SET! ,aliases (CONS (CONS NAME ALIAS) ,aliases))
NAME)
(DEFINE (,(symbol aproc '/POST-BOOT) NAME ALIAS)
(HASH-TABLE/PUT! ,aliases NAME ALIAS))
(DEFINE (,(symbol 'NAME-> sing) NAME)
(LET LOOP ((NAME NAME))
(LET ((ALIAS (HASH-TABLE/GET ,aliases NAME #F)))
(COND ((SYMBOL? ALIAS) (LOOP ALIAS))
((PROCEDURE? ALIAS) (LOOP (ALIAS)))
((HASH-TABLE/GET ,plur NAME #F))
(else (ERROR:BAD-RANGE-ARGUMENT NAME
#F))))))))))
(ill-formed-syntax form)))))
Received on Tue Nov 14 2006 - 14:18:17 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:00 UTC