| Allegro CL version 8.2 Moderate update since 8.2 release. |
Arguments: mode
This macro is designed to assist users who work in one case mode who need to use compiled files written for another mode. Case modes in Allegro CL are described in case.htm.
What in-case-mode does is complicated. It is designed as part of a more complex system to support interoperability among modes, but at the moment it is only supported for dealing with the issue of loading files compiled in one mode into a Lisp running in another mode. We give a suggested recipe for loading files compiled in a case mode different from the case mode you are using. This recipe involves using an auxiliary file. We discuss using in-case-mode directly as well, but we recommend using the procedure we describe.
Except when using in-case-mode as described here, trying to load an ANSI-Lisp compiled file into a modern Lisp signals an error. Trying to load a modern-Lisp compiled file into an ANSI Lisp does not signal an error but may nonetheless result in problems.
The value of the mode argument (which is
not evaluated) should be either :local
(corresponding to modern mode) or
:common
(corresponding to ANSI mode).
If you are running a modern mode Lisp (mlisp or equivalent), you should load an ANSI-mode compiled file foo.fasl by writing an auxilliary file aux.cl with the following contents:
(in-case-mode :common) (load "foo.fasl")
If you are running an ANSI mode Lisp (alisp or equivalent), you should load a modern-mode compiled file foo.fasl by writing an auxilliary file aux.cl with the following contents:
(in-case-mode :local) (load "foo.fasl")
You use auxiliary files because load binds relevant variables (such as
*readtable*
and
*case-translation*
) which
are affected by in-case-mode
so when the loading is complete, the values of those variables in the
Lisp calling load are
unchanged. The auxiliary file can thus be used in any Lisp, ANSI or
modern. It need not but can be compiled.
Multiple files can be loading with a single auxiliary file.
You may want to set *ignore-package-name-case*
to true when loading
files compiled in a different mode.
This method for loading files compiled in another mode does not work in all cases. Specifically, it will not work when:
*readtable*
to affect its handling of case.
We recommend loading files compiled in another mode early in a Lisp session.
When in-case-mode is called
with mode having the same value as the current
value of
*case-translation*
, nothing is done. When it
is called with mode having a different value as the current
value of
*case-translation*
,
the following occurs:
*case-translation*
is set to the
new mode.
*readtable*
(in the current thread) is the same
as (global-symbol-value *readtable*)
, the value
of *readtable*
is set to the result
of (copy-readtable nil)
. (The internal readtable
cannot be changed, but copies can be, so this step ensure the value is
a copy.)
:common
, to an upcasing readtable,
if :local
to a case-sensitive readtable).
When Lisp starts, the value returned by
case-translation-gravity and the value
of *case-translation*
are the same. When you
change the mode with in-case-mode, the value of
*case-translation*
and the value returned by
case-translation-gravity are
different (the function is unchanged, the value of the variable
changes).
When the value returned by the function is different from the value of the variable, the behavior of the functions intern, make-symbol, find-symbol, and symbol-name are changed so that effectively:
Now, in a fasl file compiled in alisp and not using the mixed case names mentioned above, all symbols are named with uppercase letters (because the reader upcased the letters when the symbol name was read). Therefore, when in an mlisp in :common mode, that fasl file is read, the symbol names are stored downcased but (while the mode is :common) referenced upcased. If the symbol AAA is encountered, its name is stored as "aaa" and it is given an alternative name "AAA" which is also stored. If the symbol CAR is encountered, the system checks for "car" and finds the Common Lisp symbol of that name. An alternative name "CAR" is created and stored for that symbol. (We will discuss what we mean by "stored" below.)
When the mode is changed back to :local, the symbol names are still
stored downcased and because case-translation-gravity and the value
of *case-translation*
are the same, the alternative names are no longer used.
We recommend using in-case-mode in an auxiliary file as described, but you can place an in-case-mode form at the top of a source file (it must be the very first form, even before the in-package form). That produces a file that can be generally loaded into any Lisp without using an auxiliary file.
You can also evaluate (in-case-mode <mode>)
at the top level and then call load to load fasl files as we suggest
doing with an auxiliary file. You should change the mode back after
the files are loaded.
Symbol objects have a normal symbol name location and an alternative
symbol name location (the exact details of where these are stored and
how they are accessed do not concern us here). When a string is
interned by intern, the string
is treated as follows. If the case-translation-gravity and the value
of *case-translation*
are the same, the name is stored as passed and nothing is stored in
the alternative name location. If the values are different and the
string is not mixed case, the string case is inverted ("AAA" to "aaa"
and "aaa" to "AAA") and stored in the normal name location, and the
unmodified name is stored in the alternative name location.
When the values are different, the functions symbol-name and find-symbol use the alternate name (when there is one) instead of the normal name.
Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page is new in the 8.2 release.
Created 2016.6.21.
| Allegro CL version 8.2 Moderate update since 8.2 release. |