[plt-scheme] Re: case-sensitive reader by default

From: Anton van Straaten (anton at appsolutions.com)
Date: Wed Apr 28 16:00:10 EDT 2004

Philippe Meunier wrote:
> Example: I recently received a piece of code from someone else.  Both
> of us are DrScheme users.  The code worked for him but not for me.
> After some debugging it turned out that his code did something like
> this:
>
> (let ([X 1])
>   (let ([x 2])
>     X))
>
> and he was implicitely relying on the case-insensitivy to have the x
> bind X.

Ouch!  If anything, that's an argument that supporting different
case-sensitivity modes via anything other than explicit declarations in
the source is a really bad idea.  Otherwise, you can never really tell
what a given piece of code is supposed to do.  Talk about ambiguous
semantics!

Note that most of the case-sensitive languages have no way of changing
their case-sensitivity.  This makes their code unambiguous with respect to
case.

If you can change case-sensitivity via menu options and command-line
switches, then you have no way of telling, when looking at PLT Scheme
source code without an explicit case-sensitivity declaration, what
case-sensitivity it is intended to run under.

Of course, this is true right now, and seems to work OK, with occasional
confusion of the sort Philippe described.  But there's one thing working
in favor of the current situation: standard Scheme code is
case-insensitive, per R5RS (Sec 2), and PLT Scheme is also
case-insensitive by default.

If you switch this situation around, you'll have old-style PLT code and
standard Scheme code which is case-insensitive, and a lot more new-style
PLT code which is case-sensitive, and no way to reliably tell the two
apart.

I might suggest that a solution to this would be to eliminate menu options
and command-line switches which change case-sensitivity, thus forcing code
to explicitly declare when it has non-default sensitivity.  But one
problem then is that if PLT chooses case-sensitivity as the default, then
strictly speaking, all standard Scheme code would require explicit
declarations of case-insensitivity, and ditto for all old-style PLT code.

If the switch in the default is made anyway, then perhaps the above could
be partly addressed via the module system: for example, anything inside a
module could be case-sensitive by default, because it must be PLT code. 
Some module languages, like R5RS, might have a different case-sensitivity
mode.  It might even be a good idea to have a standard-scheme module
language which is like mzscheme, but case-insensitive.

BTW, I notice that the list of Schemes with case-sensitivity by default is
dominated either by Schemes which are strongly oriented towards
integration with C, Java, or Unix shells (Guile, Bigloo, Gambit, Kawa,
JScheme, Scsh, PS3I); or by minor implementations, some of which seem to
be entirely moribund (Skij, Sizzle, probably others).  PLT would become
the only major "general" implementation on that list which is
case-sensitive by default (possibly joining Gauche, which I don't know
enough about to classify).

I agree with Mike Sperber, that there are ways that interoperability could
be dealt with, without necessarily making all identifiers case-sensitive
throughout the language.  I think a change like this should be considered
carefully.

Anton



Posted on the users mailing list.