aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-09-12 17:44:45 +0000
committerDave Love2000-09-12 17:44:45 +0000
commitc6ad01e8537f0e25e78b85beba56a673919a5df7 (patch)
treeaa467f835b43ee8555188949244d6655dcb2eec2
parentd12d0a9b791ed9c1959f98d7978c18644e9d438e (diff)
downloademacs-c6ad01e8537f0e25e78b85beba56a673919a5df7.tar.gz
emacs-c6ad01e8537f0e25e78b85beba56a673919a5df7.zip
Remove obsolescences, especially hash tables and refs to Emacs 19.
-rw-r--r--man/cl.texi311
1 files changed, 48 insertions, 263 deletions
diff --git a/man/cl.texi b/man/cl.texi
index 2bb30b3d792..8788e66a014 100644
--- a/man/cl.texi
+++ b/man/cl.texi
@@ -79,7 +79,7 @@ included in a translation approved by the author instead of in the
79original English. 79original English.
80@end titlepage 80@end titlepage
81 81
82@node Top, Overview,, (dir) 82@node Top, Overview, (dir), (dir)
83@chapter Common Lisp Extensions 83@chapter Common Lisp Extensions
84 84
85@noindent 85@noindent
@@ -99,7 +99,6 @@ does assume a basic familiarity with Emacs Lisp.
99* Numbers:: Predicates, functions, random numbers 99* Numbers:: Predicates, functions, random numbers
100* Sequences:: Mapping, functions, searching, sorting 100* Sequences:: Mapping, functions, searching, sorting
101* Lists:: `cadr', `sublis', `member*', `assoc*', etc. 101* Lists:: `cadr', `sublis', `member*', `assoc*', etc.
102* Hash Tables:: `make-hash-table', `gethash', etc.
103* Structures:: `defstruct' 102* Structures:: `defstruct'
104* Assertions:: `check-type', `assert', `ignore-errors'. 103* Assertions:: `check-type', `assert', `ignore-errors'.
105 104
@@ -271,11 +270,11 @@ Info files in the @file{info/} directory or another suitable place.
271 270
272You may instead wish to leave this package's components all in 271You may instead wish to leave this package's components all in
273their own directory, and then add this directory to your 272their own directory, and then add this directory to your
274@code{load-path} and (Emacs 19 only) @code{Info-directory-list}. 273@code{load-path} and @code{Info-directory-list}.
275Add the directory to the front of the list so the old @dfn{CL} 274Add the directory to the front of the list so the old @dfn{CL}
276package and its documentation are hidden. 275package and its documentation are hidden.
277 276
278@node Naming Conventions, , Installation, Overview 277@node Naming Conventions, , Installation, Overview
279@section Naming Conventions 278@section Naming Conventions
280 279
281@noindent 280@noindent
@@ -300,17 +299,11 @@ by @code{cl-}. Here is a complete list of functions @emph{not}
300prefixed by @code{cl-} which were not taken from Common Lisp: 299prefixed by @code{cl-} which were not taken from Common Lisp:
301 300
302@example 301@example
303member remove remq
304floatp-safe lexical-let lexical-let* 302floatp-safe lexical-let lexical-let*
305callf callf2 letf letf* 303callf callf2 letf letf*
306defsubst* defalias add-hook eval-when-compile 304defsubst*
307@end example 305@end example
308 306
309@noindent
310(Most of these are Emacs 19 features provided to Emacs 18 users,
311or introduced, like @code{remq}, for reasons of symmetry
312with similar features.)
313
314The following simple functions and macros are defined in @file{cl.el}; 307The following simple functions and macros are defined in @file{cl.el};
315they do not cause other components like @file{cl-extra} to be loaded. 308they do not cause other components like @file{cl-extra} to be loaded.
316 309
@@ -350,7 +343,6 @@ and the @code{eval-when} construct.
350@menu 343@menu
351* Argument Lists:: `&key', `&aux', `defun*', `defmacro*'. 344* Argument Lists:: `&key', `&aux', `defun*', `defmacro*'.
352* Time of Evaluation:: The `eval-when' construct. 345* Time of Evaluation:: The `eval-when' construct.
353* Function Aliases:: The `defalias' function.
354@end menu 346@end menu
355 347
356@iftex 348@iftex
@@ -383,7 +375,7 @@ called @var{name}; @pxref{Blocks and Exits}.
383This is just like @code{defun*}, except that the function that 375This is just like @code{defun*}, except that the function that
384is defined is automatically proclaimed @code{inline}, i.e., 376is defined is automatically proclaimed @code{inline}, i.e.,
385calls to it may be expanded into in-line code by the byte compiler. 377calls to it may be expanded into in-line code by the byte compiler.
386This is analogous to the @code{defsubst} form in Emacs 19; 378This is analogous to the @code{defsubst} form;
387@code{defsubst*} uses a different method (compiler macros) which 379@code{defsubst*} uses a different method (compiler macros) which
388works in all version of Emacs, and also generates somewhat more 380works in all version of Emacs, and also generates somewhat more
389efficient inline expansions. In particular, @code{defsubst*} 381efficient inline expansions. In particular, @code{defsubst*}
@@ -583,7 +575,7 @@ If the optimization quality @code{safety} is set to 0
583arguments and invalid keyword arguments is disabled. By default, 575arguments and invalid keyword arguments is disabled. By default,
584argument lists are rigorously checked. 576argument lists are rigorously checked.
585 577
586@node Time of Evaluation, Function Aliases, Argument Lists, Program Structure 578@node Time of Evaluation, , Argument Lists, Program Structure
587@section Time of Evaluation 579@section Time of Evaluation
588 580
589@noindent 581@noindent
@@ -671,7 +663,7 @@ certain top-level forms, like @code{defmacro} (sort-of) and
671(compile load eval) @dots{})}. 663(compile load eval) @dots{})}.
672@end defspec 664@end defspec
673 665
674Emacs 19 includes two special forms related to @code{eval-when}. 666Emacs includes two special forms related to @code{eval-when}.
675One of these, @code{eval-when-compile}, is not quite equivalent to 667One of these, @code{eval-when-compile}, is not quite equivalent to
676any @code{eval-when} construct and is described below. 668any @code{eval-when} construct and is described below.
677 669
@@ -733,23 +725,6 @@ Byte-compiled, the above defun will result in the following code
733@end example 725@end example
734@end defspec 726@end defspec
735 727
736@node Function Aliases, , Time of Evaluation, Program Structure
737@section Function Aliases
738
739@noindent
740This section describes a feature from GNU Emacs 19 which this
741package makes available in other versions of Emacs.
742
743@defun defalias symbol function
744This function sets @var{symbol}'s function cell to @var{function}.
745It is equivalent to @code{fset}, except that in GNU Emacs 19 it also
746records the setting in @code{load-history} so that it can be undone
747by a later @code{unload-feature}.
748
749In other versions of Emacs, @code{defalias} is a synonym for
750@code{fset}.
751@end defun
752
753@node Predicates, Control Structure, Program Structure, Top 728@node Predicates, Control Structure, Program Structure, Top
754@chapter Predicates 729@chapter Predicates
755 730
@@ -890,7 +865,7 @@ names. @xref{Conditionals}. @xref{Assertions}. The @code{map},
890@code{concatenate}, and @code{merge} functions take type-name 865@code{concatenate}, and @code{merge} functions take type-name
891arguments to specify the type of sequence to return. @xref{Sequences}. 866arguments to specify the type of sequence to return. @xref{Sequences}.
892 867
893@node Equality Predicates, , Type Predicates, Predicates 868@node Equality Predicates, , Type Predicates, Predicates
894@section Equality Predicates 869@section Equality Predicates
895 870
896@noindent 871@noindent
@@ -902,7 +877,7 @@ This function is almost the same as @code{eq}, except that if @var{a}
902and @var{b} are numbers of the same type, it compares them for numeric 877and @var{b} are numbers of the same type, it compares them for numeric
903equality (as if by @code{equal} instead of @code{eq}). This makes a 878equality (as if by @code{equal} instead of @code{eq}). This makes a
904difference only for versions of Emacs that are compiled with 879difference only for versions of Emacs that are compiled with
905floating-point support, such as Emacs 19. Emacs floats are allocated 880floating-point support. Emacs floats are allocated
906objects just like cons cells, which means that @code{(eq 3.0 3.0)} 881objects just like cons cells, which means that @code{(eq 3.0 3.0)}
907will not necessarily be true---if the two @code{3.0}s were allocated 882will not necessarily be true---if the two @code{3.0}s were allocated
908separately, the pointers will be different even though the numbers are 883separately, the pointers will be different even though the numbers are
@@ -942,11 +917,7 @@ respects. First, Common Lisp's @code{equalp} also compares
942in this package since Emacs does not distinguish between integers 917in this package since Emacs does not distinguish between integers
943and characters. In keeping with the idea that strings are less 918and characters. In keeping with the idea that strings are less
944vector-like in Emacs Lisp, this package's @code{equalp} also will 919vector-like in Emacs Lisp, this package's @code{equalp} also will
945not compare strings against vectors of integers. Finally, Common 920not compare strings against vectors of integers.
946Lisp's @code{equalp} compares hash tables without regard to
947ordering, whereas this package simply compares hash tables in
948terms of their underlying structure (which means vectors for Lucid
949Emacs 19 hash tables, or lists for other hash tables).
950@end defun 921@end defun
951 922
952Also note that the Common Lisp functions @code{member} and @code{assoc} 923Also note that the Common Lisp functions @code{member} and @code{assoc}
@@ -1091,7 +1062,6 @@ to standard Common Lisp.
1091 1062
1092@item 1063@item
1093The following Emacs-specific functions are also @code{setf}-able. 1064The following Emacs-specific functions are also @code{setf}-able.
1094(Some of these are defined only in Emacs 19 or only in Lucid Emacs.)
1095 1065
1096@smallexample 1066@smallexample
1097buffer-file-name marker-position 1067buffer-file-name marker-position
@@ -1424,7 +1394,7 @@ blocks for other macros like @code{incf}, @code{pushnew}, and
1424macros are used in the processing of symbol macros; 1394macros are used in the processing of symbol macros;
1425@pxref{Macro Bindings}. 1395@pxref{Macro Bindings}.
1426 1396
1427@node Customizing Setf, , Modify Macros, Generalized Variables 1397@node Customizing Setf, , Modify Macros, Generalized Variables
1428@subsection Customizing Setf 1398@subsection Customizing Setf
1429 1399
1430@noindent 1400@noindent
@@ -1859,7 +1829,7 @@ function, or a use of its name quoted by @code{quote} or
1859@code{function} to be passed on to, say, @code{mapcar}. 1829@code{function} to be passed on to, say, @code{mapcar}.
1860@end defspec 1830@end defspec
1861 1831
1862@node Macro Bindings, , Function Bindings, Variable Bindings 1832@node Macro Bindings, , Function Bindings, Variable Bindings
1863@subsection Macro Bindings 1833@subsection Macro Bindings
1864 1834
1865@noindent 1835@noindent
@@ -2064,8 +2034,8 @@ just as in Common Lisp.
2064Because they are implemented in terms of Emacs Lisp @code{catch} 2034Because they are implemented in terms of Emacs Lisp @code{catch}
2065and @code{throw}, blocks have the same overhead as actual 2035and @code{throw}, blocks have the same overhead as actual
2066@code{catch} constructs (roughly two function calls). However, 2036@code{catch} constructs (roughly two function calls). However,
2067Zawinski and Furuseth's optimizing byte compiler (standard in 2037the optimizing byte compiler will optimize away the @code{catch}
2068Emacs 19) will optimize away the @code{catch} if the block does 2038if the block does
2069not in fact contain any @code{return} or @code{return-from} calls 2039not in fact contain any @code{return} or @code{return-from} calls
2070that jump to it. This means that @code{do} loops and @code{defun*} 2040that jump to it. This means that @code{do} loops and @code{defun*}
2071functions which don't use @code{return} don't pay the overhead to 2041functions which don't use @code{return} don't pay the overhead to
@@ -2562,11 +2532,8 @@ is the opposite word of the word following @code{the}) to cause
2562hash table entry. 2532hash table entry.
2563 2533
2564@item for @var{var} being the key-codes of @var{keymap} 2534@item for @var{var} being the key-codes of @var{keymap}
2565This clause iterates over the entries in @var{keymap}. In GNU Emacs 2535This clause iterates over the entries in @var{keymap}.
256618 and 19, keymaps are either alists or vectors, and key-codes are 2536The iteration does not enter nested keymaps or inherited (parent) keymaps.
2567integers or symbols. In Lucid Emacs 19, keymaps are a special new
2568data type, and key-codes are symbols or lists of symbols. The
2569iteration does not enter nested keymaps or inherited (parent) keymaps.
2570You can use @samp{the key-bindings} to access the commands bound to 2537You can use @samp{the key-bindings} to access the commands bound to
2571the keys rather than the key codes, and you can add a @code{using} 2538the keys rather than the key codes, and you can add a @code{using}
2572clause to access both the codes and the bindings together. 2539clause to access both the codes and the bindings together.
@@ -2580,8 +2547,8 @@ them permanently. You can add a @samp{using (key-bindings ...)}
2580clause to get the command bindings as well. 2547clause to get the command bindings as well.
2581 2548
2582@item for @var{var} being the overlays [of @var{buffer}] @dots{} 2549@item for @var{var} being the overlays [of @var{buffer}] @dots{}
2583This clause iterates over the Emacs 19 ``overlays'' or Lucid 2550This clause iterates over the ``overlays'' of a buffer
2584Emacs ``extents'' of a buffer (the clause @code{extents} is synonymous 2551(the clause @code{extents} is synonymous
2585with @code{overlays}). If the @code{of} term is omitted, the current 2552with @code{overlays}). If the @code{of} term is omitted, the current
2586buffer is used. 2553buffer is used.
2587This clause also accepts optional @samp{from @var{pos}} and 2554This clause also accepts optional @samp{from @var{pos}} and
@@ -2595,13 +2562,11 @@ of start and end positions, where one start position is always equal
2595to the previous end position. The clause allows @code{of}, 2562to the previous end position. The clause allows @code{of},
2596@code{from}, @code{to}, and @code{property} terms, where the latter 2563@code{from}, @code{to}, and @code{property} terms, where the latter
2597term restricts the search to just the specified property. The 2564term restricts the search to just the specified property. The
2598@code{of} term may specify either a buffer or a string. This 2565@code{of} term may specify either a buffer or a string.
2599clause is useful only in GNU Emacs 19; in other versions, all
2600buffers and strings consist of a single interval.
2601 2566
2602@item for @var{var} being the frames 2567@item for @var{var} being the frames
2603This clause iterates over all frames, i.e., X window system windows 2568This clause iterates over all frames, i.e., X window system windows
2604open on Emacs files. This clause works only under Emacs 19. The 2569open on Emacs files. The
2605clause @code{screens} is a synonym for @code{frames}. The frames 2570clause @code{screens} is a synonym for @code{frames}. The frames
2606are visited in @code{next-frame} order starting from 2571are visited in @code{next-frame} order starting from
2607@code{selected-frame}. 2572@code{selected-frame}.
@@ -2809,7 +2774,7 @@ accumulate into the same place. From Steele:
2809 @result{} (fred bob ken sue alice joe kris sunshine june) 2774 @result{} (fred bob ken sue alice joe kris sunshine june)
2810@end example 2775@end example
2811 2776
2812@node Other Clauses, , Accumulation Clauses, Loop Facility 2777@node Other Clauses, , Accumulation Clauses, Loop Facility
2813@subsection Other Clauses 2778@subsection Other Clauses
2814 2779
2815@noindent 2780@noindent
@@ -2960,7 +2925,7 @@ and data-type specifiers. Naturally, the @code{for} clauses which
2960iterate over keymaps, overlays, intervals, frames, windows, and 2925iterate over keymaps, overlays, intervals, frames, windows, and
2961buffers are Emacs-specific extensions. 2926buffers are Emacs-specific extensions.
2962 2927
2963@node Multiple Values, , Loop Facility, Control Structure 2928@node Multiple Values, , Loop Facility, Control Structure
2964@section Multiple Values 2929@section Multiple Values
2965 2930
2966@noindent 2931@noindent
@@ -3096,7 +3061,7 @@ Most of the Common Lisp declarations are not currently useful in
3096Emacs Lisp, as the byte-code system provides little opportunity 3061Emacs Lisp, as the byte-code system provides little opportunity
3097to benefit from type information, and @code{special} declarations 3062to benefit from type information, and @code{special} declarations
3098are redundant in a fully dynamically-scoped Lisp. A few 3063are redundant in a fully dynamically-scoped Lisp. A few
3099declarations are meaningful when the optimizing Emacs 19 byte 3064declarations are meaningful when the optimizing byte
3100compiler is being used, however. Under the earlier non-optimizing 3065compiler is being used, however. Under the earlier non-optimizing
3101compiler, these declarations will effectively be ignored. 3066compiler, these declarations will effectively be ignored.
3102 3067
@@ -3187,14 +3152,12 @@ function call.
3187 3152
3188The following declarations are all equivalent. Note that the 3153The following declarations are all equivalent. Note that the
3189@code{defsubst} form is a convenient way to define a function 3154@code{defsubst} form is a convenient way to define a function
3190and declare it inline all at once, but it is available only in 3155and declare it inline all at once.
3191Emacs 19.
3192 3156
3193@example 3157@example
3194(declaim (inline foo bar)) 3158(declaim (inline foo bar))
3195(eval-when (compile load eval) (proclaim '(inline foo bar))) 3159(eval-when (compile load eval) (proclaim '(inline foo bar)))
3196(proclaim-inline foo bar) ; Lucid Emacs only 3160(defsubst foo (...) ...) ; instead of defun
3197(defsubst foo (...) ...) ; instead of defun; Emacs 19 only
3198@end example 3161@end example
3199 3162
3200@strong{Note:} This declaration remains in effect after the 3163@strong{Note:} This declaration remains in effect after the
@@ -3226,7 +3189,7 @@ and @code{safety}. The value of a quality should be an integer from
32260 to 3, with 0 meaning ``unimportant'' and 3 meaning ``very important.'' 31890 to 3, with 0 meaning ``unimportant'' and 3 meaning ``very important.''
3227The default level for both qualities is 1. 3190The default level for both qualities is 1.
3228 3191
3229In this package, with the Emacs 19 optimizing compiler, the 3192In this package, with the optimizing compiler, the
3230@code{speed} quality is tied to the @code{byte-compile-optimize} 3193@code{speed} quality is tied to the @code{byte-compile-optimize}
3231flag, which is set to @code{nil} for @code{(speed 0)} and to 3194flag, which is set to @code{nil} for @code{(speed 0)} and to
3232@code{t} for higher settings; and the @code{safety} quality is 3195@code{t} for higher settings; and the @code{safety} quality is
@@ -3361,7 +3324,7 @@ out the property and value cells.
3361@secno=2 3324@secno=2
3362@end iftex 3325@end iftex
3363 3326
3364@node Creating Symbols, , Property Lists, Symbols 3327@node Creating Symbols, , Property Lists, Symbols
3365@section Creating Symbols 3328@section Creating Symbols
3366 3329
3367@noindent 3330@noindent
@@ -3492,14 +3455,14 @@ square root of the argument.
3492@defun floor* number &optional divisor 3455@defun floor* number &optional divisor
3493This function implements the Common Lisp @code{floor} function. 3456This function implements the Common Lisp @code{floor} function.
3494It is called @code{floor*} to avoid name conflicts with the 3457It is called @code{floor*} to avoid name conflicts with the
3495simpler @code{floor} function built-in to Emacs 19. 3458simpler @code{floor} function built-in to Emacs.
3496 3459
3497With one argument, @code{floor*} returns a list of two numbers: 3460With one argument, @code{floor*} returns a list of two numbers:
3498The argument rounded down (toward minus infinity) to an integer, 3461The argument rounded down (toward minus infinity) to an integer,
3499and the ``remainder'' which would have to be added back to the 3462and the ``remainder'' which would have to be added back to the
3500first return value to yield the argument again. If the argument 3463first return value to yield the argument again. If the argument
3501is an integer @var{x}, the result is always the list @code{(@var{x} 0)}. 3464is an integer @var{x}, the result is always the list @code{(@var{x} 0)}.
3502If the argument is an Emacs 19 floating-point number, the first 3465If the argument is a floating-point number, the first
3503result is a Lisp integer and the second is a Lisp float between 3466result is a Lisp integer and the second is a Lisp float between
35040 (inclusive) and 1 (exclusive). 34670 (inclusive) and 1 (exclusive).
3505 3468
@@ -3554,7 +3517,7 @@ of @code{truncate}.
3554These definitions are compatible with those in the Quiroz 3517These definitions are compatible with those in the Quiroz
3555@file{cl.el} package, except that this package appends @samp{*} 3518@file{cl.el} package, except that this package appends @samp{*}
3556to certain function names to avoid conflicts with existing 3519to certain function names to avoid conflicts with existing
3557Emacs 19 functions, and that the mechanism for returning 3520Emacs functions, and that the mechanism for returning
3558multiple values is different. 3521multiple values is different.
3559 3522
3560@iftex 3523@iftex
@@ -3622,7 +3585,7 @@ This predicate returns @code{t} if @var{object} is a
3622@code{random-state} object, or @code{nil} otherwise. 3585@code{random-state} object, or @code{nil} otherwise.
3623@end defun 3586@end defun
3624 3587
3625@node Implementation Parameters, , Random Numbers, Numbers 3588@node Implementation Parameters, , Random Numbers, Numbers
3626@section Implementation Parameters 3589@section Implementation Parameters
3627 3590
3628@noindent 3591@noindent
@@ -3645,12 +3608,12 @@ might be slow, the code for initializing them is kept in a separate
3645function that must be called before the parameters can be used. 3608function that must be called before the parameters can be used.
3646 3609
3647@defun cl-float-limits 3610@defun cl-float-limits
3648This function makes sure that the Common Lisp floating-point 3611This function makes sure that the Common Lisp floating-point parameters
3649parameters like @code{most-positive-float} have been initialized. 3612like @code{most-positive-float} have been initialized. Until it is
3650Until it is called, these parameters will be @code{nil}. If this 3613called, these parameters will be @code{nil}. If this version of Emacs
3651version of Emacs does not support floats (e.g., most versions of 3614does not support floats, the parameters will remain @code{nil}. If the
3652Emacs 18), the parameters will remain @code{nil}. If the parameters 3615parameters have already been initialized, the function returns
3653have already been initialized, the function returns immediately. 3616immediately.
3654 3617
3655The algorithm makes assumptions that will be valid for most modern 3618The algorithm makes assumptions that will be valid for most modern
3656machines, but will fail if the machine's arithmetic is extremely 3619machines, but will fail if the machine's arithmetic is extremely
@@ -3804,7 +3767,7 @@ backwards. (Some functions, like @code{mapcar*} and @code{every},
3804@emph{do} specify exactly the order in which the function is called 3767@emph{do} specify exactly the order in which the function is called
3805so side effects are perfectly acceptable in those cases.) 3768so side effects are perfectly acceptable in those cases.)
3806 3769
3807Strings in GNU Emacs 19 may contain ``text properties'' as well 3770Strings may contain ``text properties'' as well
3808as character data. Except as noted, it is undefined whether or 3771as character data. Except as noted, it is undefined whether or
3809not text properties are preserved by sequence functions. For 3772not text properties are preserved by sequence functions. For
3810example, @code{(remove* ?A @var{str})} may or may not preserve 3773example, @code{(remove* ?A @var{str})} may or may not preserve
@@ -4039,20 +4002,6 @@ non-destructive and destructive list operations in Emacs Lisp.
4039The predicate-oriented functions @code{remove-if}, @code{remove-if-not}, 4002The predicate-oriented functions @code{remove-if}, @code{remove-if-not},
4040@code{delete-if}, and @code{delete-if-not} are defined similarly. 4003@code{delete-if}, and @code{delete-if-not} are defined similarly.
4041 4004
4042@defun remove item list
4043This function removes from @var{list} all elements which are
4044@code{equal} to @var{item}. This package defines it for symmetry
4045with @code{delete}, even though @code{remove} is not built-in to
4046Emacs 19.
4047@end defun
4048
4049@defun remq item list
4050This function removes from @var{list} all elements which are
4051@code{eq} to @var{item}. This package defines it for symmetry
4052with @code{delq}, even though @code{remq} is not built-in to
4053Emacs 19.
4054@end defun
4055
4056@defun remove-duplicates seq @t{&key :test :test-not :key :start :end :from-end} 4005@defun remove-duplicates seq @t{&key :test :test-not :key :start :end :from-end}
4057This function returns a copy of @var{seq} with duplicate elements 4006This function returns a copy of @var{seq} with duplicate elements
4058removed. Specifically, if two elements from the sequence match 4007removed. Specifically, if two elements from the sequence match
@@ -4158,7 +4107,7 @@ if no matches were found. If @code{:from-end} is true, the
4158function finds the @emph{rightmost} matching subsequence. 4107function finds the @emph{rightmost} matching subsequence.
4159@end defun 4108@end defun
4160 4109
4161@node Sorting Sequences, , Searching Sequences, Sequences 4110@node Sorting Sequences, , Searching Sequences, Sequences
4162@section Sorting Sequences 4111@section Sorting Sequences
4163 4112
4164@defun sort* seq predicate @t{&key :key} 4113@defun sort* seq predicate @t{&key :key}
@@ -4215,7 +4164,7 @@ a merged sequence which is (stably) sorted according to
4215@var{predicate}. 4164@var{predicate}.
4216@end defun 4165@end defun
4217 4166
4218@node Lists, Hash Tables, Sequences, Top 4167@node Lists, Structures, Sequences, Top
4219@chapter Lists 4168@chapter Lists
4220 4169
4221@noindent 4170@noindent
@@ -4414,7 +4363,7 @@ are compared by @code{eql} by default; you can use the @code{:test},
4414@xref{Sequences}. 4363@xref{Sequences}.
4415 4364
4416Note that this function's name is suffixed by @samp{*} to avoid 4365Note that this function's name is suffixed by @samp{*} to avoid
4417the incompatible @code{member} function defined in Emacs 19. 4366the incompatible @code{member} function defined in Emacs.
4418(That function uses @code{equal} for comparisons; it is equivalent 4367(That function uses @code{equal} for comparisons; it is equivalent
4419to @code{(member* @var{item} @var{list} :test 'equal)}.) 4368to @code{(member* @var{item} @var{list} :test 'equal)}.)
4420@end defun 4369@end defun
@@ -4497,7 +4446,7 @@ of @var{list2}, i.e., whether every element of @var{list1}
4497also appears in @var{list2}. 4446also appears in @var{list2}.
4498@end defun 4447@end defun
4499 4448
4500@node Association Lists, , Lists as Sets, Lists 4449@node Association Lists, , Lists as Sets, Lists
4501@section Association Lists 4450@section Association Lists
4502 4451
4503@noindent 4452@noindent
@@ -4541,160 +4490,11 @@ This is equivalent to @code{(nconc (mapcar* 'cons @var{keys} @var{values})
4541@var{alist})}. 4490@var{alist})}.
4542@end defun 4491@end defun
4543 4492
4544@node Hash Tables, Structures, Lists, Top
4545@chapter Hash Tables
4546
4547@noindent
4548A @dfn{hash table} is a data structure that maps ``keys'' onto
4549``values.'' Keys and values can be arbitrary Lisp data objects.
4550Hash tables have the property that the time to search for a given
4551key is roughly constant; simpler data structures like association
4552lists take time proportional to the number of entries in the list.
4553
4554@defun make-hash-table @t{&key :test :size}
4555This function creates and returns a hash-table object whose
4556function for comparing elements is @code{:test} (@code{eql}
4557by default), and which is allocated to fit about @code{:size}
4558elements. The @code{:size} argument is purely advisory; the
4559table will stretch automatically if you store more elements in
4560it. If @code{:size} is omitted, a reasonable default is used.
4561
4562Common Lisp allows only @code{eq}, @code{eql}, @code{equal},
4563and @code{equalp} as legal values for the @code{:test} argument.
4564In this package, any reasonable predicate function will work,
4565though if you use something else you should check the details of
4566the hashing function described below to make sure it is suitable
4567for your predicate.
4568
4569Some versions of Emacs (like Lucid Emacs 19) include a built-in
4570hash table type; in these versions, @code{make-hash-table} with
4571a test of @code{eq} will use these built-in hash tables. In all
4572other cases, it will return a hash-table object which takes the
4573form of a list with an identifying ``tag'' symbol at the front.
4574All of the hash table functions in this package can operate on
4575both types of hash table; normally you will never know which
4576type is being used.
4577
4578This function accepts the additional Common Lisp keywords
4579@code{:rehash-size} and @code{:rehash-threshold}, but it ignores
4580their values.
4581@end defun
4582
4583@defun gethash key table &optional default
4584This function looks up @var{key} in @var{table}. If @var{key}
4585exists in the table, in the sense that it matches any of the existing
4586keys according to the table's test function, then the associated value
4587is returned. Otherwise, @var{default} (or @code{nil}) is returned.
4588
4589To store new data in the hash table, use @code{setf} on a call to
4590@code{gethash}. If @var{key} already exists in the table, the
4591corresponding value is changed to the stored value. If @var{key}
4592does not already exist, a new entry is added to the table and the
4593table is reallocated to a larger size if necessary. The @var{default}
4594argument is allowed but ignored in this case. The situation is
4595exactly analogous to that of @code{get*}; @pxref{Property Lists}.
4596@end defun
4597
4598@defun remhash key table
4599This function removes the entry for @var{key} from @var{table}.
4600If an entry was removed, it returns @code{t}. If @var{key} does
4601not appear in the table, it does nothing and returns @code{nil}.
4602@end defun
4603
4604@defun clrhash table
4605This function removes all the entries from @var{table}, leaving
4606an empty hash table.
4607@end defun
4608
4609@defun maphash function table
4610This function calls @var{function} for each entry in @var{table}.
4611It passes two arguments to @var{function}, the key and the value
4612of the given entry. The return value of @var{function} is ignored;
4613@var{maphash} itself returns @code{nil}. @xref{Loop Facility}, for
4614an alternate way of iterating over hash tables.
4615@end defun
4616
4617@defun hash-table-count table
4618This function returns the number of entries in @var{table}.
4619@strong{Warning:} The current implementation of Lucid Emacs 19
4620hash-tables does not decrement the stored @code{count} when
4621@code{remhash} removes an entry. Therefore, the return value of
4622this function is not dependable if you have used @code{remhash}
4623on the table and the table's test is @code{eq}. A slower, but
4624reliable, way to count the entries is @code{(loop for x being the
4625hash-keys of @var{table} count t)}.
4626@end defun
4627
4628@defun hash-table-p object
4629This function returns @code{t} if @var{object} is a hash table,
4630@code{nil} otherwise. It recognizes both types of hash tables
4631(both Lucid Emacs built-in tables and tables implemented with
4632special lists.)
4633@end defun
4634
4635Sometimes when dealing with hash tables it is useful to know the
4636exact ``hash function'' that is used. This package implements
4637hash tables using Emacs Lisp ``obarrays,'' which are the same
4638data structure that Emacs Lisp uses to keep track of symbols.
4639Each hash table includes an embedded obarray. Key values given
4640to @code{gethash} are converted by various means into strings,
4641which are then looked up in the obarray using @code{intern} and
4642@code{intern-soft}. The symbol, or ``bucket,'' corresponding to
4643a given key string includes as its @code{symbol-value} an association
4644list of all key-value pairs which hash to that string. Depending
4645on the test function, it is possible for many entries to hash to
4646the same bucket. For example, if the test is @code{eql}, then the
4647symbol @code{foo} and two separately built strings @code{"foo"} will
4648create three entries in the same bucket. Search time is linear
4649within buckets, so hash tables will be most effective if you arrange
4650not to store too many things that hash the same.
4651
4652The following algorithm is used to convert Lisp objects to hash
4653strings:
4654
4655@itemize @bullet
4656@item
4657Strings are used directly as hash strings. (However, if the test
4658function is @code{equalp}, strings are @code{downcase}d first.)
4659
4660@item
4661Symbols are hashed according to their @code{symbol-name}.
4662
4663@item
4664Integers are hashed into one of 16 buckets depending on their value
4665modulo 16. Floating-point numbers are truncated to integers and
4666hashed modulo 16.
4667
4668@item
4669Cons cells are hashed according to their @code{car}s; nonempty vectors
4670are hashed according to their first element.
4671
4672@item
4673All other types of objects hash into a single bucket named @code{"*"}.
4674@end itemize
4675
4676@noindent
4677Thus, for example, searching among many buffer objects in a hash table
4678will devolve to a (still fairly fast) linear-time search through a
4679single bucket, whereas searching for different symbols will be very
4680fast since each symbol will, in general, hash into its own bucket.
4681
4682The size of the obarray in a hash table is automatically adjusted
4683as the number of elements increases.
4684
4685As a special case, @code{make-hash-table} with a @code{:size} argument
4686of 0 or 1 will create a hash-table object that uses a single association
4687list rather than an obarray of many lists. For very small tables this
4688structure will be more efficient since lookup does not require
4689converting the key to a string or looking it up in an obarray.
4690However, such tables are guaranteed to take time proportional to
4691their size to do a search.
4692
4693@iftex 4493@iftex
4694@chapno=18 4494@chapno=18
4695@end iftex 4495@end iftex
4696 4496
4697@node Structures, Assertions, Hash Tables, Top 4497@node Structures, Assertions, Lists, Top
4698@chapter Structures 4498@chapter Structures
4699 4499
4700@noindent 4500@noindent
@@ -5241,22 +5041,7 @@ do check their keyword arguments for validity.
5241@appendixsec Optimizing Compiler 5041@appendixsec Optimizing Compiler
5242 5042
5243@noindent 5043@noindent
5244The byte-compiler that comes with Emacs 18 normally fails to expand 5044Use of the optimizing Emacs compiler is highly recommended; many of the Common
5245macros that appear in top-level positions in the file (i.e., outside
5246of @code{defun}s or other enclosing forms). This would have
5247disastrous consequences to programs that used such top-level macros
5248as @code{defun*}, @code{eval-when}, and @code{defstruct}. To
5249work around this problem, the @dfn{CL} package patches the Emacs
525018 compiler to expand top-level macros. This patch will apply to
5251your own macros, too, if they are used in a top-level context.
5252The patch will not harm versions of the Emacs 18 compiler which
5253have already had a similar patch applied, nor will it affect the
5254optimizing Emacs 19 byte-compiler written by Jamie Zawinski and
5255Hallvard Furuseth. The patch is applied to the byte compiler's
5256code in Emacs' memory, @emph{not} to the @file{bytecomp.elc} file
5257stored on disk.
5258
5259Use of the Emacs 19 compiler is highly recommended; many of the Common
5260Lisp macros emit 5045Lisp macros emit
5261code which can be improved by optimization. In particular, 5046code which can be improved by optimization. In particular,
5262@code{block}s (whether explicit or implicit in constructs like 5047@code{block}s (whether explicit or implicit in constructs like
@@ -5356,7 +5141,7 @@ The @code{member}, @code{floor}, @code{ceiling}, @code{truncate},
5356by @samp{*} in this package to avoid collision with existing 5141by @samp{*} in this package to avoid collision with existing
5357functions in Emacs. The older package simply 5142functions in Emacs. The older package simply
5358redefined these functions, overwriting the built-in meanings and 5143redefined these functions, overwriting the built-in meanings and
5359causing serious portability problems with Emacs 19. (Some more 5144causing serious portability problems. (Some more
5360recent versions of the Quiroz package changed the names to 5145recent versions of the Quiroz package changed the names to
5361@code{cl-member}, etc.; this package defines the latter names as 5146@code{cl-member}, etc.; this package defines the latter names as
5362aliases for @code{member*}, etc.) 5147aliases for @code{member*}, etc.)
@@ -5432,7 +5217,7 @@ package. The newer @code{floor*} and friends return their two
5432results in a list rather than as multiple values. Note that 5217results in a list rather than as multiple values. Note that
5433older versions of the old package used the unadorned names 5218older versions of the old package used the unadorned names
5434@code{floor}, @code{ceiling}, etc.; @code{cl-compat} cannot use 5219@code{floor}, @code{ceiling}, etc.; @code{cl-compat} cannot use
5435these names because they conflict with Emacs 19 built-ins. 5220these names because they conflict with Emacs built-ins.
5436 5221
5437@node Porting Common Lisp, Function Index, Old CL Compatibility, Top 5222@node Porting Common Lisp, Function Index, Old CL Compatibility, Top
5438@appendix Porting Common Lisp 5223@appendix Porting Common Lisp
@@ -5575,7 +5360,7 @@ Emacs Lisp's @code{format} would rarely be useful.
5575@item 5360@item
5576Vector constants use square brackets in Emacs Lisp, but 5361Vector constants use square brackets in Emacs Lisp, but
5577@code{#(a b c)} notation in Common Lisp. To further complicate 5362@code{#(a b c)} notation in Common Lisp. To further complicate
5578matters, Emacs 19 introduces its own @code{#(} notation for 5363matters, Emacs has its own @code{#(} notation for
5579something entirely different---strings with properties. 5364something entirely different---strings with properties.
5580 5365
5581@item 5366@item
@@ -5651,7 +5436,7 @@ recursion.
5651 5436
5652@printindex fn 5437@printindex fn
5653 5438
5654@node Variable Index, , Function Index, Top 5439@node Variable Index, , Function Index, Top
5655@unnumbered Variable Index 5440@unnumbered Variable Index
5656 5441
5657@printindex vr 5442@printindex vr