The index for the Allegro CL Documentation is in index.htm. The documentation is described in introduction.htm.
This document contains the following sections:
1.0 Implementation introductionThe Common Lisp standard is deliberately vague on many of the specifics of an implementation. The authors of that book were, correctly, aware that implementation details are dependent on the nature of the hardware and the operating system, as well as the differing priorities of the implementors and the different user communities. This document details some of the specifics of the implementation of and extensions in Allegro CL.
Allegro CL contains all of the required Common Lisp data types. Fixnums are signed 30-bit quantities. Bignums may be as large as 2**[1,048,576]. There are two distinct floating-point types. Short-float and single-float are equivalent. Double-float and long-float are equivalent. The distinct array data types are the following (in the case of the simple arrays, we use suspension points, `...', to indicate that there may be any number of dimensions):
(array t) (array bit) (array (unsigned-byte 4)) (array (unsigned-byte 8)) (array (unsigned-byte 16)) (array (unsigned-byte 32)) (array (unsigned-byte 64)) [64-bit Lisps only] (array character) (array single-float) (array double-float) (array (complex single-float)) (array (complex double-float)) (array (signed-byte 8)) (array (signed-byte 16)) (array (signed-byte 32)) (array (signed-byte 64)) [64-bit Lisps only] (simple-array t (* ...)) (simple-array bit (* ...)) (simple-array (unsigned-byte 4) (* ...)) (simple-array (unsigned-byte 8) (* ...)) (simple-array (unsigned-byte 16) (* ...)) (simple-array (unsigned-byte 32) (* ...)) (simple-array (unsigned-byte 64) (* ...)) [64-bit Lisps only] (simple-array character (* ...)) (simple-array single-float (* ...)) (simple-array double-float (* ...)) (simple-array (signed-byte 8) (* ...)) (simple-array (signed-byte 16) (* ...)) (simple-array (signed-byte 32) (* ...)) (simple-array (signed-byte 64) (* ...)) [64-bit Lisps only]
X3J13, the ANSI subcommittee chartered to propose a specification for the forthcoming ANSI Common Lisp, has voted to make several changes to Common Lisp's treatment of characters. The intent of these changes is to clean up ideas that are felt not to have worked out in pre-ANSI Common Lisp as well as to allow for Common Lisp to be extensible to international languages. Unfortunately, some of these changes affect backward compatibility and storage efficiency. The result is that Franz Inc. has had to make some user-visible changes that may affect code which explicitly makes arrays or vectors of type character.
X3J13 has removed discussion of bit and font attributes of characters from the Common Lisp language. The string-char type specifier has also been removed from the language by X3J13. Finally, strings are now equivalent to (vector character) for creation purposes. X3J13 allows characters to be attributed with bit/font features as described in CLtL, but in an implementation-dependent way.
ANSI compatible Allegro CL continues to support font/bit attributes of characters. For example, the reader and printer acts on such characters in the pre-ANSI CL way (e.g., #\control-a is #\a with the control bit set, #3\meta-b is #\b with font 3 and the meta bit set). What's more, functions operating on bits and fonts from pre-ANSI CL (e.g., string-char-p, char-bits, char-font, make-char) are available in the cltl1 package.
Because Franz Inc. wants to achieve as much backward compatibility as possible with code using pre-ANSI font/bit attributed characters, and because Franz Inc. also wants to represent strings at least as efficiently as they have been in pre-ANSI versions of Allegro CL, difficulties arise in representing attributed characters in strings (which are now vectors of characters instead of vectors of string-chars). What ANSI-compatible Allegro CL does is to specify that it is an error to store attributed characters in a string. What in fact happens if one tries to do so is that the attributes are stripped. Thus an attributed character that has been stored in an array and extracted is no longer attributed and no longer EQL to its previous value.
Although this behavior violates the spirit of how elements are stored in arrays, this behavior was chosen by Franz Inc. because (a) pre-ANSI CL code using fonts/bits will not have been storing attributed characters into strings since it has always been an error to do so, and (b) representing strings as arrays that can hold attributed characters would have made strings less efficient and incompatible with existing foreign function code that uses strings.
In other words, portable ANSI CL code should not notice this
compromise and pre-ANSI CL code should mostly be able to run as before
with very little source change. The one area where portable pre-ANSI
CL may run into problems is in places where the character type
specifier is explicitly specified in calls to make-array, or to
sequence functions that create a vector. (Such sequence functions
include coerce, map, concatenate, etc.) These places in pre-ANSI CL
where the character type specifier is used should most likely be
changed to specify the t
type specifier. In
pre-ANSI versions of Allegro CL (array character) was equivalent to
(array t).
Allegro CL has the ability to autoload certain files and modules. In order to keep the size of the system down by excluding parts not always needed, some of Allegro CL is not included in the system when it is built. These parts must be loaded in when they are required. This section describes how that code is loaded in.
All the fasl files which have the potential to be autoloaded are part of the Allegro CL library. All the files are collected into a single file called the bundle file. Its filename is files and its type depends on the version of Allegro CL, but is always some variant of [letter]bu, for example files.bu and files.ebu. The bundle file is located in the Allegro directory. It contains a set of fasl files which can be loaded individually (the whole file is not loaded when a part is). The function bundle-pathname returns the pathname of the bundle file.
Code for some Common Lisp functions and macros (notably
trace, inspect, and step) are contained in
modules separate from the default binary. (The modules are called
:trace, :inspect, and :step.) Whenever any Common Lisp function or
macro is called, the necessary module will be loaded
automatically. Note that using auxiliary features provided as
extensions (such as referring to the variable *trace-print-length*
) will not cause the
module to be loaded. Even though the modules can be automatically
loaded, we recommend explicitly loading those that you need with a
call to require, as described
below.
The code for major extensions, such as the foreign function interface or multiprocessing, also is loaded when needed instead of being in the default Lisp binary. Again, calls to some functions will cause the correct module to be loaded, but we recommend loading the module before using the facility, using require, as described next.
While most modules will be loaded automatically when an important function or macro defined in the module is called, you have to load modules explicitly to use some of the less central functionality. Some users also prefer to explicitly load modules in order to save waiting when the module is actually needed.
To load a module with require, simply enter the form:
(require :module-name)
It is useful to put this form at the beginning of any source file containing code which uses symbols in the module. It is not an error to call require when the module is already loaded.
This section describes certain extensions to Common Lisp and provides details of their implementation.
5.1 Extensions to
cl:make-package, cl:disassemble, cl:open
5.2 cl:directory
5.3 Reader macros and cl:*features*
5.4 cl:random
5.5 cl:make-hash-table
5.6 cl:make-array
Certain standard Common Lisp functions have been extended in minor ways in Allegro CL. Elsewhere we describe changes to load Using the load function in loading.htm for the general implementation, Load foreign code with cl:load in foreign-functions.htm (for loading foreign code) and sleep (in Process functions and variables (both models) in multiprocessing.htm, making it work on a per-process basis). Those functions were extended to do something essentially new (load to load foreign functions and fasl files in libfasl mode, sleep to work on single processes). The extensions mentioned in this section refer to changes in the semantics of some Common Lisp functions which affect the way they are ordinarily used. The sort of changes done include allowing strings denoting objects as input as well as the object itself. In some cases we have added boolean variables which control the extended behavior, allowing you to decide exactly how you want Lisp to work.
Arguments: package-name &key use implementation-packages
The implementation-packages keyword argument is an Allegro CL extension described fully in packages.htm. Its value should be a list. Otherwise, this function works as specified in the ANSI specification. The default for the use argument is implementation-dependent. The default in Allegro CL is a list containing one element, the common-lisp package.
Arguments: name-or-compiled-function &key absolute references-only recurse
The standard disassemble does not have any keyword arguments. Both are extensions which are likely not supported in implementations of Common Lisp other than Allegro CL.
In standard CL, name-or-compiled-function should be a function-object, a lambda expression, or a symbol with a function definition. Allegro CL also accepts function names which are lists as well (see 7.0 Function specs for a discussion of function names which are lists).
name-or-compiled-function can also be a string. A string is interpreted as naming a foreign (C or Fortran) function. The string must match the name identified by applying nm (or similar system function) to the current symbol table. This is often the result of applying convert-to-lang to the routine name, but there are exceptions -- e.g. Lisp internal routines typically do not have a prepended underscore. name-or-compiled-function can also be a codevector. These are extensions to Common Lisp.
If the value of the absolute keyword argument
is nil
(the default), then relative pc
addresses are given, starting at 0. If the value of
absolute is true, addresses
are given as absolute addresses. Note that these addresses are
consistent within a single disassembly, but any gc activity may have
moved the code vector by the time the disassembly is done.
The recurse keyword argument, if true, causes
internal functions to be disassembled after the specified function. It
defaults to t
if the
name-or-compiled-function represents a function
and if references-only is not specified.
If the references-only keyword argument is
specified true (its default value is nil
) then no disassembly is printed. Instead, a list
is returned of all references the function identified by the required
argument makes (from either the function object or the global table)
to any Lisp object.
There are other keyword arguments to disassemble but they are not for programmer use.
Arguments: file &key direction element-type if-exists if-does-not-exist class &allow-other-keys
The specification of this Common Lisp function allows a great deal of latitude to the implementation since interfacing with file systems is hard to specify generally. Here we discuss the if-exists and class keyword arguments.
The if-exists argument is looked at only if
the direction argument is specified as
:io
or :output
. In that case the
following values are allowed for if-exists and
have the effect described.
:error
signals an error. :new-version
is treated just like :supersede
, which is
discussed below. (Unix does not support file versions.) :rename
renames the old file to a new file using the function that is the
value of the special symbol *open-rename-function*
.
The variables *open-rename-prefix*
and *open-rename-suffix*
are also used.:rename-and-delete
first renames the file following the conventions of :rename
,
then creates the new file, then deletes the renamed file if the creation was successful. :overwrite
opens the file for destructive modification. Although the file
pointer initially points to the beginning of the file, the file is not truncated to zero
length upon opening. :append
opens the file for destructive modification. The file pointer
initially points to the end of the file. :supersede
creates a new file that replaces the existing file. nil
creates neither a file nor a stream. nil
is returned. The open function has been
further extended to take a class keyword
argument. open passes this
argument to make-instance when it creates the stream,
and as with make-instance, the
argument may be a stream class object or a symbol naming such a
class. If the class argument is not supplied or
is nil
, open selects one of the following built-in
classes according to the direction and
element-type arguments:
excl::character-input-file-stream excl::character-output-file-stream excl::character-bidirectional-file-stream excl::binary-input-file-stream excl::binary-output-file-stream excl::binary-bidirectional-file-stream
These classes all contain file-stream
and are
variously mixed with
fundamental-character-input-stream fundamental-character-output-stream fundamental-binary-input-stream fundamental-binary-output-stream
Although the file-stream subclasses returned by open are all instantiable, at present they require hidden initialization (for element-type upgrading, buffer allocation, etc.) and therefore they should only be created using open. It is fine to further specialize them, but you are required to create instances of your specializations of these stream classes using the :class keyword argument to open rather than by calling make-instance yourself.
open is also modified with &allow-other-keys and &rest to pass all keyword arguments as initialization arguments to make-instance. This has the unfortunate side effect of removing error checking for misspelled keyword arguments. A useful future enhancement might be to code some explicit checks which are executed when the class keyword argument is not given.
See streams.htm.
The directory function has had a keyword argument added to it to assist in recursive walks down a directory tree. (Note that even though the new argument is not specified, Common Lisp: the Language says the following about directory: `It is anticipated that an implementation may need to provide additional parameters to control the directory search. Therefore directory is specified to take additional keyword arguments so that implementations may experiment with extensions, even though no particular keywords are specified here.')
Arguments: path &key directories-are-files
Returns a list of pathnames matching path,
which may be a pathname, string, symbol or stream. Returns nil
if there is no match.
If the keyword argument directories-are-files
is specified true (the default), this function
will return directories as files (that is pathnames with name and/or
type components true). If the argument is nil
, directories are returned as directories
(pathnames with name and type components nil
). In the latter case it is possible to walk down
a directory tree recursively using directory.
The elements of the list returned by directory is in the same order as returned by the associated system function (e.g. readir() on UNIX).
We have extended the #+ and #- reader macros to accept
(version>= N [ M]) as an argument. It is interpreted to mean that
the form following will only be read if the version (also called
release) of Allegro CL is greater than or equal to N.M. The N must be
supplied. The M is optional. Both must be integers. With #+,
version>= signifies read the next form only if the version is
greater than or equal to N.M. With #-, it means read the next form
only is the version is less than N.M. For example, because of an X3J13
change, the element type for an array of characters is
character
starting in release 4.1 and
string-char
in earlier releases. To have code work
in all Allegro CL releases, do the following:
(make-array 3 :element-type #+(version>= 4 1) 'character #-(version>= 4 1) 'string-char)
Warning: while most Common Lisp implementations (including Allegro CL prior to version 4.1) ignore `(version>=...)', it is possible that an implementation would signal an error upon encountering it. As a workaround for truly portable code, use:
#+(and allegro-version>= (version>=...))
Because :allegro-version>= is (presumably) only on the *features* list of Allegro CL 4.1 (and later), this will fail in all versions without version>= having to have a definition.
This standard Common Lisp variable can be used with the #+ and #-
reader macros to conditionalize code for different Lisp
implementations and releases. The exact value is different in every
version of Allegro CL. Here are some useful values which may or may
not be in your version. Please check the value of *features*
in your version to
see exactly what is there. The function featurep can be used to test whether a feature
is present or not.
Table 3.3: Features present or missing from *features* in Allegro CL | |
Feature | Meaning and use |
:allegro | Unique to Allegro CL. Present in all versions on all platforms. Use this to distinguish Allegro CL from other Lisp implementations. |
:x3j13 | Purports to conform to some version of Common Lisp specified by the ANSI X3J13 committee. Present in Allegro CL version 4.2, 4.3, and later. |
:cltl2 | Purports to conform to Common Lisp: the Language, 2nd ed. Since ANSI Lisp has diverged, :x3j13 and :cltl2 should not both be present. Not present in Allegro CL 4.2, 4.3, or later. Present in some earlier versions. |
:draft-ansi-cl-2 | Purports to conform to the second draft ANSI standard. Allegro CL does so, so :draft-ansi-cl-2 is present in Allegro CL 6.0 |
:ansi-cl | Purports to conform to ANSI Common Lisp standard. The standard is now (since early 1996) final. Present in Allegro CL starting with version 4.3. |
:dynload | Foreign loading is done by dynamic linking of shared libraries/objects. The next three features are types of dynamic loading. See foreign-functions.htm. |
:dlfcn | Uses dlopen() to link foreign code. OS examples: Solaris, IRIX, Dec Unix, AIX. See foreign-functions.htm. |
:dlhp | Uses shl_load to link foreign code. HP only. See foreign-functions.htm. |
:dlwin | Uses LoadLibrary to link foreign code. Windows machines only. See foreign-functions.htm. |
:dlld | Loads .o files into image with ld. No Allegro CL version uses this. |
:ics | Supports International Character sets. Characters are 16-bits (rather than 8 bits). Allegro CL comes in both International and non-International versions (the International version is standard). Use this feature to distinguish the versions. See iacl.htm. |
:os-threads | Multiprocessing model uses native threads. Other model is the non :os-threads model (no special feature) where processes are managed within Lisp. See multiprocessing.htm. |
:mswindows | Appears in versions running on Windows machines. Use #-mswindows for Unix. |
:sparc | This feature appears on versions that run on machines with a Sparc processor (e.g. Sun 4's and Sparcstations). A similar platform-naming feature appears in all implementations and allows differentiating between machines. Look for the feature in your version. |
:big-endian | Platform uses the big-endian method of representing numbers. |
:little-endian | The platform uses the little-endian method of representing numbers. |
:allegro-v6.0 | Present in Allegro CL version 6.0. See also #+(version>= reader macro defined 5.3 Reader macros and cl:*features* above. Both it and this feature are useful for conditionalizing code to run on different releases of Allegro CL. |
There are two random number generators used in Allegro CL, depending on the argument to random. One is fast, efficient, and does no consing but is only used when the argument is 1.0f0 (i.e.single-float 1.0) or a fixnum. The other, which is slower and less efficient and conses a great deal, is used when the argument to random is something other than 1.0f0 or a fixnum.
We recommend that users interested in random floats of magnitude X do
(* x (random 1.0f0))
rather than
(random x)
Arguments: number &optional state
Returns a pseudo-random number uniformly distributed between 0 and (- number 1) if number is an integer and between 0 (inclusive) and number (exclusive) if number is real but not an integer. number must be real and positive. state should be a random-state object. If supplied, it will be made the state while the returned value is calculated.
If number is a fixnum or the single-float 1.0, the algorithm used to generate the result is Algorithm A on page 27 of Art of Computer Programming, volume 2, 2nd edition, by Donald Knuth (published by Addison-Wesley). If number is any other value, a linear-congruential generator using 48 bit integers for the seed and multiplier is used. because 48 bit integers are bignums, random with an argument other than a fixnum or the single-float 1.0 is very inefficient and not recommended.
A "random" random state, generated by
(make-random-state t)
, uses get-universal-time for its starting value. If
you need many different "random" random states, do not
generate them in a tight loop because get-universal-time might return the same value
more than once within the loop (get-universal-time has a resolution of one
second and a tight loop can run many many times in one second). Put a
(sleep 1)
in the loop to ensure get-universal-time returns different
values. (Two initial values differing only in the last digit will
produce different seeds.) Compare:
(dotimes (i 5) (print (make-random-state t)))
with
(dotimes (i 5) (sleep 1) (print (make-random-state t)))
Arguments: number &key test size rehash-size rehash-threshold hash-function values weak-keys
Hash tables with standard tests (eq, eql, equal, and equalp) have been optimized in Allegro CL to make putting values into and getting values from a hash table fast. eq hashtables are the fastest, followed closely by eql, and then equal and equalp.
Allegro CL has also extended make-hash-table in several ways:
The hash-function keyword argument allows further specialization when standard functionality is inefficient (usually because of excessive collisions caused by bunching of the hash codes of the data). Code that uses the hash-function argument is not portable Common Lisp, of course.
If specified, the value from hash-function should be a function of one argument which reproducibly returns an integer between 0 and 65535 (inclusive) when applied to any Lisp object intended to be used as a hash key. Reproducibly here means the function will return the same value on equivalent objects whenever it is called. hash-function defaults to sxhash except when test is one of the four standard tests (eq, eql, equal, equalp) when hash-function defaults to an internal function optimized for that test. (For equal and equalp, the hash-function is an internal version of sxhash.)
test should be a symbol naming a function of
two arguments that returns t
or nil
as two keys are or are not equivalent. The
standard values for test are eq, eql,
equal, and equalp (or the associated function objects
#'eq
etc.) but any test function can be
specified. (But note (1) that symbol
is reserved
for internal use. test should not be specified
'symbol
in application or user code and (2) the
value must be a symbol naming a function, not a function object; the
four standard function objects listed just above are accepted as
values but no other function objects.) If
hash-function is specified, it is the
programmer's responsibility to ensure the test function and the hash
function work together correctly and consistently.
weak-keys defaults to nil
, which specifies the default behavior. When
weak-keys is specified as t
, the keys of the resulting hash table are
treated specially by the garbage-collector: when a key in such a hash
table has no more references to it, the entire entry is removed from
the hash table, and the hash-table-count is decremented. This entry
removal will occur regardless of whether :values :weak
is
specified (which by itself will never affect the hash-table-count, but
only the value of an entry). See gc.htm for
information on weak objects.
If weak-keys is given the value
:tenurable
, then the key vector (the part of the
weak-key hash-table that is normally kept in newspace) is allowed to
be tenured. Any other true value for weak-keys
causes the key vector to be forced to stay in newspace (but it is best
to use t
as this allows other non-nil
values which have special meaning to be added
later). The :tenurable
option is new for 6.0, and
allows the amount of data copied between newspace halves to remain
smaller than if the key vector were forced to remain in newspace. This
difference can be large if the hash-table is large. Allegro CL 6.0 now
uses this option internally for a shared-cons hash-table. If a
tenurable weak-keys hash-table must be rehashed due to growth, the new
key vector is allocated in newspace, but is still allowed to be
tenured. (This means the vector is not created with
:allocation :old
described below.)
The downside of tenuring the weak-key vector is that
references to the values will remain until a global garbage collection
examines the weak-key vector. An untenured weak-key vector is examined
whenever there is a scavenge. Global gc's are typically rare, but
scavenges occur regularly. A decision to use the
:tenurable
option should take this into
consideration.
values defaults to t
,
which specifies that the hash table will contain both a key and a
value for each entry. If :values :weak
is
specified, then the hash table will only hold the value as long as it
is referenced non-weakly by some other object. If no other objects
reference the value, it becomes nil
and a
gethash on the key will return
nil
for the value (the value is
collected by the gc). If values is specified as
nil
, then a sans values hash table
is created, and only keys are stored as the actual values. For this
kind of hash-table, maphash
will call the function with a nil
as the
value argument, in place of an actual value (but the key will be
passed in as usual). Also, gethash returns the stored key as the value
(which is not necessarily eq
to the given key argument), and a new function puthash-key is defined for storing into these
hash-tables.
Arguments: dims &key allocation element-type weak [and other standard CL keyword args not listed here]
allocation is discussed first and then weak.
allocation: make-array, a standard Common Lisp function, has
been extended to accept the allocation keyword
argument. The value of this argument must be one of the following
keywords (the default is :new
, which produces the
behavior of earlier releases).
Value of allocation argument | Meaning |
:new | Allocate the new array data in new space (the usual behavior). Any array element type accepted. This is the default. |
:old | Allocate the new array data in old space immediately (without waiting for it to survive for the required number of scavenges). Any array element type accepted. |
:static | Allocate the new array in malloc (foreign) space. The array will never be touched by the garbage collector and must be deallocated explicitly. Only a restricted number of element types are supported for static arrays. They are listed below. :malloc and :static are synonyms. |
:malloc | |
:static-reclaimable | Allocate the new array data in malloc (foreign) space and the header in Lisp space. The data will never be touched by the garbage collector but it will be deallocated when there are no pointers from Lisp (using a finalization). Only a restricted number of element types are supported for static arrays. They are listed below. |
:lispstatic-reclaimable | Allocate the new array in malloc (foreign) space. The array will never be touched by the garbage collector until there are no pointers from Lisp, at which point the whole array will be deallocated explicitly. Any Lisp type can be contained in the array. |
allocation is not a standard Common Lisp argument to make-array so programmers may wish to conditionalize it with #+allegro to preserve code portability.
If allocation is :static
or
:malloc
or :static-reclaimable
,
element-type must be specified and be one of the
following:
bit (signed-byte 8) (unsigned-byte 4) (unsigned-byte 8) (signed-byte 16) (unsigned-byte 16) (signed-byte 32) (unsigned-byte 32) character single-float double-float (complex single-float) (complex double-float)
Having created a static array, you may wish to free it. To do this, first pass the array to the function lispval-other-to-address, which will return an address (an integer). That address can be passed to aclfree. Note: if you reference the array after it has been freed, you will get garbage values. If you set a value in the array after it has been freed, you may cause Lisp to fail.
weak: make-array, a standard Common Lisp function, has
been extended to accept the weak keyword
argument. weak is not a standard Common Lisp
argument to make-array so
programmers may wish to conditionalize it with #+allegro to preserve
code portability. weak may be true (meaning
create a weak array) or nil
(meaning create a
standard array). The default is nil
.
A Lisp object becomes garbage when nothing points to or references it. The way the garbage collector works is it finds and identifies live objects (often then moving them somewhere). Whatever is left is garbage. Weak arrays allow pointers to objects which will not, however, keep them alive. If one of these pointers exists, the garbage collector will see the item and (depending on the circumstances), either keep it alive or abandon it.
If you specify weak true, you cannot specify
the non-standard allocation argument or the
standard displaced-to argument. The only values
accepted for the standard element-type argument
are those for which no specialized array type for that element-type is
defined (i.e. upgraded-array-element-type applied to
element-type should return t
, which
in essense means you should not specify element-type).
See Weak arrays and hashtables in gc.htm for more information on weak arrays.
Arguments: stream
Allegro CL allows stream to be a pathname or a string naming a file as well as a stream open to a file (ANSI CL specifies only a stream open to a file). This function returns the size of the file.
Often you wish to write floating point numbers to a file which is read later, perhaps in the same Lisp invocation but more likely in a different one. The simple way to do this, writing the decimal represntation of the floats, suffers from being very inefficient and somewhat inexact. (It is expensive to convert the internal binary representation to decimal for writing, and then the decimal representation back to binary when the values are read.)
Allegro CL provides functions that write and read the binary representation of floats (rather than the decimal representation), thus saving the time and loss of accuracy associated with conversion to and from decimal format. The functions are single-float-to-shorts, double-float-to-shorts, shorts-to-single-float, and shorts-to-double-float. Note that machine binary representations are used by most languages, and so, just as Allegro CL can read the files produced by writing the integers returned by single-float-to-shorts and convert them back to floating point numbers, programs easily written in other languages can do so as well.
An additional version optional argument has been added to cl:provide and cl:require. It allows specifying a minimal version acceptable for loading a module.
Arguments: module-name &optional version
The non-standard version argument, if specified, should be a positive real number (a float or an integer). This value is checked when the module specified by module-name is loaded. If the cl:require form also specified a version, it is compared (numerically) with the version in the provide form. If the require version is less than the provide version, a continuable error is signaled. If either form does not have a version specified, there will be no error.
Arguments: module-name &optional pathname min-version
The non-standard min-version argument, if specified, should be an positive real number (a float or an integer). This value is compared with the version specified in the cl:provide form in the module. An error will be signaled if the cl:provide form has a version less than the value of min-version. If the cl:provide form has no version specified (or there is no cl:provide), no error will be signaled.
While investigating ways to speed up Allegro CL, developers at Franz determined that pretty printing was a significant user of compute cycles, and that turning pretty printing off produced significant speedup of code that did output. This conclusion is not particularly suprising, of course. It takes work to produce pretty output. The question is, what to do about it. Turning off pretty printing sounds easier than it is.
Allegro CL starts with *print-pretty*
set to
t
and further, the value in *cl-default-special-bindings*
is (essentially) t
as well. So simply setting
*print-pretty*
to nil
will
not work because the true value will tend to return unexpectedly (in
new processes, for example).
Further, user code may depend on the initial value of
*print-pretty*
being t
, so
the initial value could not be changed.
However, we can make suggestions to users so that they can achieve the speedups when desired.
There are three steps.
(1) change the value of *print-pretty*
in *cl-default-special-bindings*
to nil
by evaluating
(setq *print-pretty* nil) (tpl:setq-default *print-pretty* nil)
(See setq-default.)
(2) avoid using format strings that are pretty-printing by nature
(such as ~
<
... ~:$gt;
).
(3) Set the value of *pprint-gravity*
to
nil
. Code in Allegro CL that used to bind
*print-pretty*
to t
now
bind it to *pprint-gravity*
. That variable is
not set on the *cl-default-special-bindings*
list.
There is a module pprint.fasl. When loaded into
an image, it sets *print-pretty*
and
*pprint-gravity*
to t
. This module is loaded automatically when an image
is built with a standard top-level. However, when an image is built
with a minimal top-level (as described in Minimal top
levels in building-images.htm, the
pprint
module is not loaded.
So when building an image, you can include them for a development image (above), putting them in, say, custom.cl, or you can build the image with a minimal top-level.
Note that the guts of pretty-printing are in the
pprint
module. Whenever a format statement, or a
print statement with *print-pretty*
set to t
, is executed, the pprint module is required, so
that the machinery is present to do the pretty-printing. So you have
to be careful to avoid such cases. If you need pretty printing, you
should use the strategy present above rather than a minimal top-level
strategy.
Please check the Allegro CL FAQ from time to time to see if there is new information on this issue.
There are now 64-bit implementations of Allegro CL for some platforms that support 64-bit operations. In release 6.0, the Compaq Alpha (formerly DEC ALpha) and the HP-PA platforms have 64-bit Allegro CL available.
For the most part there is no compatibility issue, especially when dealing with Lisp. The exceptions are:
-DAcl32Bit
or -DAcl64Bit
on the
cc line of any program which includes it, for any architectures for
which there are both 32-bit ports and 64-bit ports (Compaq Alpha for
6.0). It is a good idea to add the -DAcl32Bit option to cc lines
to be sure as additional platforms may be added later.
:int
, :long
,
:unsigned-int
, and
:unsigned-long
types always follow precisely the
sizes of the foreign modules that are successfully loaded into that
Lisp.
Again, most pure-lisp behavior will be completely portable between 32-bit and 64-bit lisps, and that at most a user is likely only to see wider values while inspecting objects, or larger addresses in room displays.
For operations that must deal with specific sizes but do not use the def-foreign-type interface, the natural type (in Lisp) and the nat type (in C) provides a simple method to allow compatibility between 32-bit and 64-bit lisp code and foreign modules.
The same HP machine can run in 32-bit and 64-bit modes, and different libraries, etc. are used for the different modes. Users should be aware that the settings of environment variables (such as LPATH, SHLIB_PATH, and LD_LIBRARY_PATH) appropriate for one mode may be inappropriate for the other. Bad settings can cause problems for Lisp (when, for example, it executes shell commands). These problems often manifest themselves with strange and unexpected errors or problems. If you experience strange and unexpected errors and problems, consider whether the cause is inappropriate settings of environment variables.
Allegro CL 6.0 is an implementation of Common Lisp as specified by the ANSI X3J13 committee. The standard of conformance has been accepted by ANSI as final. ANSI is the American National Standards Institute, and the X3J13 committee prepared the ANSI standard for Common Lisp.
Common Lisp was originally specified in Common Lisp: the Language, 1st edition (CLtL-1). That standard is now out of date. Common Lisp: the Language, 2nd edition (CLtL-2) describes an earlier version of the ANSI standard. It is still used but please understand that the final ANSI standard has diverged in a number of ways from CLtL-2, so CLtL-2 is no longer definitive.
The several symbols removed from the language by X3J13 but
preserved by Allegro CL for backward compatibility are exported from
the cltl1
package. These generally retain their CLtL-1
definitions. We list the symbols exported from the cltl1
package at the end of this section.
Two symbols exported from the flavors
package conflict
with symbols now exported from the common-lisp package as part of
CLOS: defmethod and make-instance. This means that no
package can use the flavors package without shadowing these two
symbols. See the code at the beginning of
flavors.htm.
The following symbols in the cltl1 package have been deleted from standard Common Lisp by X3J13. They (for the most part) maintain their CLtL-1 functionality. You may use the cltl1 package to get backward compatibility but we recommend that you write all new code so that you do not use these symbols and that you modify all existing code as soon as practical. See appendix A for more information on why the symbol was removed from the standard. (An index maps symbols to listed actions. Where possible, the actions give the CLtL-2 page reference where more information is provided.)
Note that special-form-p is in the cltl1 package. That symbol was previously in the common-lisp package but has been replaced in that package with the symbol special-operator-p.
These symbols were in the cltl1
package since
release 4.0 and are still there:
applyhook *applyhook* *break-on-warnings* char-bit char-bits char-bits-limit char-control-bit char-font char-font-limit char-hyper-bit char-meta-bit char-super-bit compiler-let evalhook *evalhook* int-char make-char set-char-bit string-char string-char-p define-setf-method get-setf-method-multiple-value get-setf-method special-form-p
X3J13 made a number of improvements to the package system in order to facilitate portability and to regularize the handling of top-level forms in a file. The function in-package was changed to a macro, and its various keyword arguments were deleted. The macro expansion of in-package is defined to have effect at compile, load, and eval times, but no longer creates a package if it does not exist, nor modifies any existing package. These functionalities are subsumed by the new defpackage macro, along with that of the several other package-manipulating functions. The package name argument to in-package is no longer evaluated. Execution of an in-package form referencing an unknown package or containing optional arguments signals a continuable error.
The variable *cltl1-in-package-compatibility-p*
makes
in-package work as it did in CLtL-1 Common Lisp. Users porting
code from Allegro CL for Windows 3.0.x (which used CLtL-1 semantics in
this regard) may find this variable useful. We do recommend modifying
the code in the long run, however.
By compile-time-too behavior, we refer to the effect of certain top-level forms in a file being compiled. In CLtL-1, top-level forms which were calling the functions listed below were treated as if they were wrapped in an
(eval-when (compile))
form. That behavior has been changed in the new standard and you must wrap such forms in appropriate eval-when forms if they are to have effect while a file is being compiled. The affected functions are:
proclaim make-package shadow shadowing-import import export unexport use-package unuse-package require
The variable *cltl1-compile-file-toplevel-compatibility-p*
can be used to get CLtL-1 compile-time-too behavior when compiling
files. Users porting code from Allegro CL for Windows 3.0.x (which
used CLtL-1 semantics in this regard) may find this variable
useful. We do recommend modifying the code in the long run,
however.
X3J13 tightened the definition of the function data type, primarily
so generic functions could discriminate on functional arguments. It
was necessary that the type represented by the function datatype and
functionp predicate be disjoint from all other datatypes. Therefore,
in Allegro CL since version 4.2 the only objects that are type
function are those returned by the function special form, or by the
compile function given a first argument of nil
, or by coerce of a lambda expression to type
function, or functions loaded from a compiled file. X3J13 specifies
that the funcall and apply functions will continue to accept a
symbol for the first argument, but a symbol is no longer
functionp, nor are lists beginning with
lambda
, sometimes called lambda expressions. For
backward compatibility the funcall and apply functions
in Allegro CL will still accept a lambda expression, as is permitted
by X3J13, but as required by X3J13 lambda expressions no longer
satisfy functionp nor (typep function)
.
Previous versions of Allegro CL have used Portable Common Loops (PCL) as a substitute for the Common Lisp Object System (CLOS) which was adopted by X3J13 as a standard part of Common Lisp. The last several versions of PCL worked in most ways the same as CLOS and provided most of the required features. (Some unavoidable divergences of PCL from CLOS derived from the dependence of CLOS on certain other incompatible language changes.)
Since CLOS replaces PCL completely, there has been no attempt to port any version of PCL to Allegro CL 4.3. Doing such a port would be difficult, and would not benefit from the significant speed advantages of the native CLOS implementation in Allegro CL. User code that depends on various details of PCL (especially internals) may have temporary difficulties, but in any case such code will someday need to be brought into conformance with CLOS. In addition to full conformance with CLOS, of course, the other advantage of the native CLOS implementation is its greatly enhanced runtime performance.
CLOS is documented in chapter 28 of CLtL-2. MOP is documented in the book The Art of MetaObject Protocol.
It is possible to trace, disassemble, and compile CLOS methods by name. Here is an example of tracing.
USER(14): (defmethod my-function ((x integer)) (cons x :integer)) #<clos:standard-method my-function ...> USER(15): (my-function 1) (1 . :integer) USER(16): (trace ((method my-function (integer)))) ((method my-function (integer))) USER(17): (my-function 1) 0: ((method my-function (integer)) 1) 0: returned (1 . :integer) (1 . :integer) USER(18): (untrace (method my-function (integer))) ((method my-function (integer))) USER(19): (my-function 1) (1 . :integer) USER(20):
Here is how to trace setf,
:before
, and :after
methods (the
names and argument types will likely be different in your case, of
course):
(trace ((method (setf slot-1) (t baz)))) (trace ((method foo :before (integer)))) (trace ((method foo :after (integer))))
The extra set of parentheses is required to avoid confusion with specifying trace options (they are specified with a list whose car is the function to be traced and whose cdr is a possibly empty list of options). Note that the extra set of parentheses is not used with untrace:
(untrace (method (setf slot-1) (t baz))) (untrace (method foo :before (integer))) (untrace (method foo :after (integer)))
A generic function itself can be traced exactly like any other function.
We list known non-conformances with CLOS and MOP. The basic format is to list the object that is unimplemented or only partially implemented with a brief description of the non-conformance. Unqualified symbols are part of CLOS and are exported from the common-lisp package. Symbols qualified with clos: are part of MOP (they are exported from the clos package).
[Generic function] clos:class-prototype
Implemented for clos::std-class only. clos::std-class (which is not part of the CLOS standard) is a superclass of funcallable-standard-class and standard-class but is not a superclass of forward-referenced-class, structure-class, and built-in-class. Therefore, methods are defined on the first two classes but not the next three. (This is not actually a non-conformance.)
[Special form] generic-flet
Removed from spec by X3J13 and not implemented.
[Macro]
generic-function
Removed from spec by X3J13 and not implemented.
[Special form] generic-labels
Removed from spec by X3J13 and not implemented.
[Generic function]
clos:make-method-lambda
Not implemented.
[Special form] with-added-methods
Removed from spec by X3J13 and not implemented.
Calls to make-instance where the class-name is a quoted constant and each of the keywords is a constant are transformed by the compiler into calls to constructor functions. A constructor function is a piece of code that is equivalent to the make-instance call except that it is significantly (10 to 100 times) faster.
The optimization is automatic when the call to make-instance is formed in a particular way. In order for an optimized constructor function to be used certain restrictions apply:
Generic function | Condition for optimization |
make-instance | Only system supplied methods are applicable |
initialize-instance | Only system supplied standard method and user-supplied :after
methods are applicable |
shared-initialize | Only system supplied standard method and user-supplied :after
methods are applicable |
The calls to make-instance are replaced by calls to the constructor regardless of whether an optimized constructor can be used. The first time the constructor function is called, the restrictions are tested and if they do not apply, an optimized constructor is generated. When the restrictions are not obeyed the constructor calls make-instance. Redefining a class or one of its superclasses or adding/removing a method to one of the generic functions mentioned above causes the constructor function to be recomputed.
A function spec (fspec) is a list that denotes a place to store a
function. Function specs are useful for functions that don't otherwise
have obvious names. ANSI CL defines Function Names as either symbols
or the lists formed by (setf
[symbol])
[to denote a writer function to
pair with the reader function named by [symbol] which
may or may not itself be defined]. Allegro CL extends the Function
Name concept by defining function specs, and allows the user to create
new kinds of function specs. Some pre-defined function spec names in
Allegro CL are :discriminator
,
:effective-method
, method
,
flet
, labels
,
:internal
, :top-level-form
,
etc.
Function specs are normally kept in an internal form, which allows many of the cons cells in various fspecs to be shared. They are converted to the normal external format usually only when printing, or at other times when parsing the internal form is too complex. Handlers of fspecs must be aware of these internal formats and may use the following functions to access their components: fspec-first, fspec-second, fspec-third.
Each of these functions will work on either an internal or external fspec, and will for an external fspec return the first, second, or third element, respectively (i.e. just like first, second, and third). If the fspec is in internal form, the proper corresponding element is still returned, but without the overhead of first converting to an external fspec.
Users can define their own function specs with def-function-spec-handler.
The C function GetWinMainArgs2 in the Allegro CL dll (which has a name like acly6xxx.dll, where the y, if present, is a letter and the x's are digits) is used by the IDE to retrieve Windows handle information known by the ACL runtime system. This information may also be useful for applications written in Lisp. The information returned by this function should be used carefully and non-destructively as the ACL runtime system (i.e. the low-level routines in Allegro CL, unrelated to Allegro Runtime) depends on these handles to exist and behave in predicatable ways.
In order to use this function you must use the foreign function interface to create a Lisp function to call the C function:
(ff:def-foreign-call (GetWinMainArgs2 "GetWinMainArgs2") ((vec (:array :int)) (count :int)) :returning :void)
Next create a vector of five raw integers for the function to fill in:
(setq myvec (make-array 5 :element-type '(unsigned-byte 32)))
Now call the function with the vector followed by the number of elements in the vector
(GetWinMainArgs2 myvec (length myvec))
The vector now contains the following information
index value 0: The Windows instance handle of the lisp process
index value 1: The previous Windows instance handle (which is always zero).
index value 2: unused
index value 3: The Windows handle of the console window (if there is one).
index value 4: The Windows handle of the splash window. Normally the splash window is gone by the time the application starts up, but the +B command-line argument to mlisp.exe can cause the splash window to stay up longer. If this value is non-zero then the application is permitted to call the Windows function DestroyWindow() on it to make the splash window disappear. If this value is zero then the splash window is already gone.
The following list describes the (mostly minor or obscure) known non-compliances of Allegro CL with the ANSI spec.
nil
. nil
is tailp of any true
list. nil
. nil
signals an error,
and it should not. call-next-method
with changed arguments does not check
that the set of applicable methods has not changed, though it should in safe (safety=3)
code. nil
in the expansion should surround
the entire form, not just the body forms, but in Allegro CL wraps the block nil
only
around the body forms. (do-external-symbols and do-all-symbols
are correctly implemented with regard to this point.) the
clause. The expansion should not literally include the the
form, but the
effect of the type declaration may be effectuated by the compiler by some other means.
Allegro CL does not conform, and the expansion of a symbol-macrolet
variable with a type declaration includes a the
form. nil
for purposes of type checking. In Allegro CL in
interpreted code, an error is signalled unless a the form agrees exactly
with both the number and types of the returned values. However, in compiled code, it does
not check values returned through a the form (although the type declaration may be used
for code optimization) and therefore complies. nil
. Allegro CL incorrectly generates the
additional block nil
. Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved. Created 2000.10.5.