set-case-mode

Function

Package: excl

Arguments: new mode

This function sets the case mode of Lisp to that specified by the new-mode argument. The value of that argument must be one of the following three keywords: :case-insensitive-upper, :case-insensitive-lower, and :case-sensitive-lower.

set-case-mode converts the running Lisp to use the new mode for subsequent reading and returns a keyword denoting the previous mode. This function must do quite a bit of consistency checking when changing between modes with different case preferences, and may take as long as several minutes to complete. As we say below, it is much better to use an image with the desired case mode rather than changing the case mode after the image has started.

Note that the typical case mode for Release 6.0 is :case-sensitive-lower. Release 6.0 is distributed with modern (:case-sensitive-lower) images (named mlisp and mlisp8) and ANSI (:case-insensitive-upper) images (named alisp and alisp8). Rather than changing case mode after starting, it is best to start the image with the desired case mode.

If Lisp is built with the Presto feature, this function will not allow users to destructively change symbol names from uppercase to lowercase or lowercase to uppercase. set-case-mode will always allow uses to change the reader sensitivity. (If a Lisp is built with :presto t specified to build-lisp-image, then the Lisp is built with Allegro Presto.)

If CLX has been loaded into Lisp, you cannot change the case mode at all with this function. Unfortunately, no error is signaled but problems will occur later. Note that both Allegro Composer and Allegro Common Windows (both only available on Unix) use CLX.

This function can be called at any time but should, if possible, be called as the first action in a fresh invocation of Lisp (and better would be to use the image with the desired case mode and do not use this function at all). Note that the system will not be able to resolve conflicts if case mode is changed after Lisp has been running for some time. However, sometimes it is necessary to change case modes more than once. Suppose you want to work in case-sensitive, lowercase preferred mode but need to load files written for a standard (case-insensitive, uppercase) Lisp. You might first set the mode to :case-insensitive-lower, load the files, and then set the mode to the desired :case-sensitive-lower.

Since set-case-mode alters the names of symbols in the currently running lisp environment, users are advised not to use this function lightly as it may introduce subtle problems. The following Lisp session illustrates:

The initial set of commands establishes state and demonstrates that case is preserved by the reader in a case-sensitive-lower (modern-mode) lisp:

cl-user(1): (defparameter mixed-sym-name "aBc")
mixed-sym-name
cl-user(2): (defparameter mixed-sym (read-from-string mixed-sym-name))
mixed-sym
cl-user(3): mixed-sym
aBc
cl-user(4): (eq mixed-sym (read-from-string mixed-sym-name))
t

The subsequent set of commands demonstrates that taking a round-trip through case-mode conversions (from modern-mode to ansi-mode back to modern-mode) affects the lisp environment. We assume convert-mixed-case-symbols returns true, which is the default in Release 6.0.

cl-user(5): (set-case-mode :case-insensitive-upper)
:CASE-SENSITIVE-LOWER
CL-USER(6): (set-case-mode :case-sensitive-lower)
:case-insensitive-upper
cl-user(7): mixed-sym
abc
cl-user(8): (eq mixed-sym (read-from-string mixed-sym-name))
nil
cl-user(9): 

See also case.htm, *current-case-mode*, *ignore-package-name-case*, and convert-mixed-case-symbols.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.