diff options
| author | Glenn Morris | 2012-11-03 10:56:30 -0700 |
|---|---|---|
| committer | Glenn Morris | 2012-11-03 10:56:30 -0700 |
| commit | 685b00269debcb77f533f65ba5e6421d8539229d (patch) | |
| tree | 27151c7c52ab67a2f97eefa1586fe1efcd029ce0 /doc | |
| parent | 77f6eafecaee05fcd62b03f7c7d01961bcd31ec8 (diff) | |
| download | emacs-685b00269debcb77f533f65ba5e6421d8539229d.tar.gz emacs-685b00269debcb77f533f65ba5e6421d8539229d.zip | |
Further edits for doc/misc/cl.texi
* cl.texi: Further general copyedits.
(List Functions): Remove copy-tree, standard elisp for some time.
(Efficiency Concerns): Comment out examples that no longer apply.
(Compiler Optimizations): Rename from "Optimizing Compiler"; reword.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/misc/ChangeLog | 3 | ||||
| -rw-r--r-- | doc/misc/cl.texi | 111 |
2 files changed, 52 insertions, 62 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 39d7ee8d1fc..6bd601bef5d 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | 2012-11-03 Glenn Morris <rgm@gnu.org> | 1 | 2012-11-03 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * cl.texi: Further general copyedits. | 3 | * cl.texi: Further general copyedits. |
| 4 | (List Functions): Remove copy-tree, standard elisp for some time. | ||
| 5 | (Efficiency Concerns): Comment out examples that no longer apply. | ||
| 6 | (Compiler Optimizations): Rename from "Optimizing Compiler"; reword. | ||
| 4 | 7 | ||
| 5 | 2012-11-02 Glenn Morris <rgm@gnu.org> | 8 | 2012-11-02 Glenn Morris <rgm@gnu.org> |
| 6 | 9 | ||
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index 66d25144dd6..593985edbfc 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi | |||
| @@ -2867,6 +2867,7 @@ temporary variables. | |||
| 2867 | This function creates a new, uninterned symbol (using @code{make-symbol}) | 2867 | This function creates a new, uninterned symbol (using @code{make-symbol}) |
| 2868 | with a unique name. (The name of an uninterned symbol is relevant | 2868 | with a unique name. (The name of an uninterned symbol is relevant |
| 2869 | only if the symbol is printed.) By default, the name is generated | 2869 | only if the symbol is printed.) By default, the name is generated |
| 2870 | @c FIXME no longer true? | ||
| 2870 | from an increasing sequence of numbers, @samp{G1000}, @samp{G1001}, | 2871 | from an increasing sequence of numbers, @samp{G1000}, @samp{G1001}, |
| 2871 | @samp{G1002}, etc. If the optional argument @var{x} is a string, that | 2872 | @samp{G1002}, etc. If the optional argument @var{x} is a string, that |
| 2872 | string is used as a prefix instead of @samp{G}. Uninterned symbols | 2873 | string is used as a prefix instead of @samp{G}. Uninterned symbols |
| @@ -3207,7 +3208,7 @@ may appear in any order. | |||
| 3207 | The @code{:key} argument should be passed either @code{nil}, or a | 3208 | The @code{:key} argument should be passed either @code{nil}, or a |
| 3208 | function of one argument. This key function is used as a filter | 3209 | function of one argument. This key function is used as a filter |
| 3209 | through which the elements of the sequence are seen; for example, | 3210 | through which the elements of the sequence are seen; for example, |
| 3210 | @code{(cl-find x y :key 'car)} is similar to @code{(cl-assoc x y)}: | 3211 | @code{(cl-find x y :key 'car)} is similar to @code{(cl-assoc x y)}. |
| 3211 | It searches for an element of the list whose @sc{car} equals | 3212 | It searches for an element of the list whose @sc{car} equals |
| 3212 | @code{x}, rather than for an element which equals @code{x} itself. | 3213 | @code{x}, rather than for an element which equals @code{x} itself. |
| 3213 | If @code{:key} is omitted or @code{nil}, the filter is effectively | 3214 | If @code{:key} is omitted or @code{nil}, the filter is effectively |
| @@ -3225,7 +3226,7 @@ true (non-@code{nil}) to indicate a match; instead, you may use | |||
| 3225 | @code{:test-not} to give a function which returns @emph{false} to | 3226 | @code{:test-not} to give a function which returns @emph{false} to |
| 3226 | indicate a match. The default test function is @code{eql}. | 3227 | indicate a match. The default test function is @code{eql}. |
| 3227 | 3228 | ||
| 3228 | Many functions which take @var{item} and @code{:test} or @code{:test-not} | 3229 | Many functions that take @var{item} and @code{:test} or @code{:test-not} |
| 3229 | arguments also come in @code{-if} and @code{-if-not} varieties, | 3230 | arguments also come in @code{-if} and @code{-if-not} varieties, |
| 3230 | where a @var{predicate} function is passed instead of @var{item}, | 3231 | where a @var{predicate} function is passed instead of @var{item}, |
| 3231 | and sequence elements match if the predicate returns true on them | 3232 | and sequence elements match if the predicate returns true on them |
| @@ -3239,7 +3240,7 @@ and sequence elements match if the predicate returns true on them | |||
| 3239 | to remove all zeros from sequence @code{seq}. | 3240 | to remove all zeros from sequence @code{seq}. |
| 3240 | 3241 | ||
| 3241 | Some operations can work on a subsequence of the argument sequence; | 3242 | Some operations can work on a subsequence of the argument sequence; |
| 3242 | these function take @code{:start} and @code{:end} arguments which | 3243 | these function take @code{:start} and @code{:end} arguments, which |
| 3243 | default to zero and the length of the sequence, respectively. | 3244 | default to zero and the length of the sequence, respectively. |
| 3244 | Only elements between @var{start} (inclusive) and @var{end} | 3245 | Only elements between @var{start} (inclusive) and @var{end} |
| 3245 | (exclusive) are affected by the operation. The @var{end} argument | 3246 | (exclusive) are affected by the operation. The @var{end} argument |
| @@ -3347,7 +3348,7 @@ the return values using @code{nconc}. | |||
| 3347 | @defun cl-some predicate seq &rest more-seqs | 3348 | @defun cl-some predicate seq &rest more-seqs |
| 3348 | This function calls @var{predicate} on each element of @var{seq} | 3349 | This function calls @var{predicate} on each element of @var{seq} |
| 3349 | in turn; if @var{predicate} returns a non-@code{nil} value, | 3350 | in turn; if @var{predicate} returns a non-@code{nil} value, |
| 3350 | @code{some} returns that value, otherwise it returns @code{nil}. | 3351 | @code{cl-some} returns that value, otherwise it returns @code{nil}. |
| 3351 | Given several sequence arguments, it steps through the sequences | 3352 | Given several sequence arguments, it steps through the sequences |
| 3352 | in parallel until the shortest one runs out, just as in | 3353 | in parallel until the shortest one runs out, just as in |
| 3353 | @code{cl-mapcar}. You can rely on the left-to-right order in which | 3354 | @code{cl-mapcar}. You can rely on the left-to-right order in which |
| @@ -3396,7 +3397,7 @@ of left-associative: | |||
| 3396 | @equiv{} (- 1 (- 2 (- 3 4))) @result{} -2 | 3397 | @equiv{} (- 1 (- 2 (- 3 4))) @result{} -2 |
| 3397 | @end example | 3398 | @end example |
| 3398 | 3399 | ||
| 3399 | If @code{:key} is specified, it is a function of one argument which | 3400 | If @code{:key} is specified, it is a function of one argument, which |
| 3400 | is called on each of the sequence elements in turn. | 3401 | is called on each of the sequence elements in turn. |
| 3401 | 3402 | ||
| 3402 | If @code{:initial-value} is specified, it is effectively added to the | 3403 | If @code{:initial-value} is specified, it is effectively added to the |
| @@ -3465,7 +3466,7 @@ of data copied is simply the shorter of the source and destination | |||
| 3465 | If @var{seq1} and @var{seq2} are @code{eq}, then the replacement | 3466 | If @var{seq1} and @var{seq2} are @code{eq}, then the replacement |
| 3466 | will work correctly even if the regions indicated by the start | 3467 | will work correctly even if the regions indicated by the start |
| 3467 | and end arguments overlap. However, if @var{seq1} and @var{seq2} | 3468 | and end arguments overlap. However, if @var{seq1} and @var{seq2} |
| 3468 | are lists which share storage but are not @code{eq}, and the | 3469 | are lists that share storage but are not @code{eq}, and the |
| 3469 | start and end arguments specify overlapping regions, the effect | 3470 | start and end arguments specify overlapping regions, the effect |
| 3470 | is undefined. | 3471 | is undefined. |
| 3471 | @end defun | 3472 | @end defun |
| @@ -3488,7 +3489,7 @@ if @var{count} was also specified). | |||
| 3488 | @end defun | 3489 | @end defun |
| 3489 | 3490 | ||
| 3490 | @defun cl-delete item seq @t{&key :test :test-not :key :count :start :end :from-end} | 3491 | @defun cl-delete item seq @t{&key :test :test-not :key :count :start :end :from-end} |
| 3491 | This deletes all elements of @var{seq} which match @var{item}. | 3492 | This deletes all elements of @var{seq} that match @var{item}. |
| 3492 | It is a destructive operation. Since Emacs Lisp does not support | 3493 | It is a destructive operation. Since Emacs Lisp does not support |
| 3493 | stretchable strings or vectors, this is the same as @code{cl-remove} | 3494 | stretchable strings or vectors, this is the same as @code{cl-remove} |
| 3494 | for those sequence types. On lists, @code{cl-remove} will copy the | 3495 | for those sequence types. On lists, @code{cl-remove} will copy the |
| @@ -3588,7 +3589,7 @@ elements match (according to @code{:test}, @code{:test-not}, | |||
| 3588 | and @code{:key}), the function returns @code{nil}. If there is | 3589 | and @code{:key}), the function returns @code{nil}. If there is |
| 3589 | a mismatch, the function returns the index (relative to @var{seq1}) | 3590 | a mismatch, the function returns the index (relative to @var{seq1}) |
| 3590 | of the first mismatching element. This will be the leftmost pair of | 3591 | of the first mismatching element. This will be the leftmost pair of |
| 3591 | elements which do not match, or the position at which the shorter of | 3592 | elements that do not match, or the position at which the shorter of |
| 3592 | the two otherwise-matching sequences runs out. | 3593 | the two otherwise-matching sequences runs out. |
| 3593 | 3594 | ||
| 3594 | If @code{:from-end} is true, then the elements are compared from right | 3595 | If @code{:from-end} is true, then the elements are compared from right |
| @@ -3603,7 +3604,7 @@ which compares two strings case-insensitively. | |||
| 3603 | @defun cl-search seq1 seq2 @t{&key :test :test-not :key :from-end :start1 :end1 :start2 :end2} | 3604 | @defun cl-search seq1 seq2 @t{&key :test :test-not :key :from-end :start1 :end1 :start2 :end2} |
| 3604 | This function searches @var{seq2} for a subsequence that matches | 3605 | This function searches @var{seq2} for a subsequence that matches |
| 3605 | @var{seq1} (or part of it specified by @code{:start1} and | 3606 | @var{seq1} (or part of it specified by @code{:start1} and |
| 3606 | @code{:end1}.) Only matches which fall entirely within the region | 3607 | @code{:end1}). Only matches that fall entirely within the region |
| 3607 | defined by @code{:start2} and @code{:end2} will be considered. | 3608 | defined by @code{:start2} and @code{:end2} will be considered. |
| 3608 | The return value is the index of the leftmost element of the | 3609 | The return value is the index of the leftmost element of the |
| 3609 | leftmost match, relative to the start of @var{seq2}, or @code{nil} | 3610 | leftmost match, relative to the start of @var{seq2}, or @code{nil} |
| @@ -3614,7 +3615,7 @@ function finds the @emph{rightmost} matching subsequence. | |||
| 3614 | @node Sorting Sequences | 3615 | @node Sorting Sequences |
| 3615 | @section Sorting Sequences | 3616 | @section Sorting Sequences |
| 3616 | 3617 | ||
| 3617 | @defun clsort seq predicate @t{&key :key} | 3618 | @defun cl-sort seq predicate @t{&key :key} |
| 3618 | This function sorts @var{seq} into increasing order as determined | 3619 | This function sorts @var{seq} into increasing order as determined |
| 3619 | by using @var{predicate} to compare pairs of elements. @var{predicate} | 3620 | by using @var{predicate} to compare pairs of elements. @var{predicate} |
| 3620 | should return true (non-@code{nil}) if and only if its first argument | 3621 | should return true (non-@code{nil}) if and only if its first argument |
| @@ -3625,7 +3626,7 @@ numbers into decreasing rather than increasing order. | |||
| 3625 | 3626 | ||
| 3626 | This function differs from Emacs's built-in @code{sort} in that it | 3627 | This function differs from Emacs's built-in @code{sort} in that it |
| 3627 | can operate on any type of sequence, not just lists. Also, it | 3628 | can operate on any type of sequence, not just lists. Also, it |
| 3628 | accepts a @code{:key} argument which is used to preprocess data | 3629 | accepts a @code{:key} argument, which is used to preprocess data |
| 3629 | fed to the @var{predicate} function. For example, | 3630 | fed to the @var{predicate} function. For example, |
| 3630 | 3631 | ||
| 3631 | @example | 3632 | @example |
| @@ -3636,7 +3637,7 @@ fed to the @var{predicate} function. For example, | |||
| 3636 | sorts @var{data}, a sequence of strings, into increasing alphabetical | 3637 | sorts @var{data}, a sequence of strings, into increasing alphabetical |
| 3637 | order without regard to case. A @code{:key} function of @code{car} | 3638 | order without regard to case. A @code{:key} function of @code{car} |
| 3638 | would be useful for sorting association lists. It should only be a | 3639 | would be useful for sorting association lists. It should only be a |
| 3639 | simple accessor though, it's used heavily in the current | 3640 | simple accessor though, since it's used heavily in the current |
| 3640 | implementation. | 3641 | implementation. |
| 3641 | 3642 | ||
| 3642 | The @code{cl-sort} function is destructive; it sorts lists by actually | 3643 | The @code{cl-sort} function is destructive; it sorts lists by actually |
| @@ -3692,7 +3693,7 @@ i.e., chains of cons cells. | |||
| 3692 | 3693 | ||
| 3693 | @defun cl-caddr x | 3694 | @defun cl-caddr x |
| 3694 | This function is equivalent to @code{(car (cdr (cdr @var{x})))}. | 3695 | This function is equivalent to @code{(car (cdr (cdr @var{x})))}. |
| 3695 | Likewise, this package defines all 28 @code{c@var{xxx}r} functions | 3696 | Likewise, this package defines all 24 @code{c@var{xxx}r} functions |
| 3696 | where @var{xxx} is up to four @samp{a}s and/or @samp{d}s. | 3697 | where @var{xxx} is up to four @samp{a}s and/or @samp{d}s. |
| 3697 | All of these functions are @code{setf}-able, and calls to them | 3698 | All of these functions are @code{setf}-able, and calls to them |
| 3698 | are expanded inline by the byte-compiler for maximum efficiency. | 3699 | are expanded inline by the byte-compiler for maximum efficiency. |
| @@ -3720,7 +3721,8 @@ This function returns the length of list @var{x}, exactly like | |||
| 3720 | @code{(length @var{x})}, except that if @var{x} is a circular | 3721 | @code{(length @var{x})}, except that if @var{x} is a circular |
| 3721 | list (where the @sc{cdr}-chain forms a loop rather than terminating | 3722 | list (where the @sc{cdr}-chain forms a loop rather than terminating |
| 3722 | with @code{nil}), this function returns @code{nil}. (The regular | 3723 | with @code{nil}), this function returns @code{nil}. (The regular |
| 3723 | @code{length} function would get stuck if given a circular list.) | 3724 | @code{length} function would get stuck if given a circular list. |
| 3725 | See also the @code{safe-length} function.) | ||
| 3724 | @end defun | 3726 | @end defun |
| 3725 | 3727 | ||
| 3726 | @defun cl-list* arg &rest others | 3728 | @defun cl-list* arg &rest others |
| @@ -3748,18 +3750,6 @@ This function returns a copy of the list @var{list}. It copies | |||
| 3748 | dotted lists like @code{(1 2 . 3)} correctly. | 3750 | dotted lists like @code{(1 2 . 3)} correctly. |
| 3749 | @end defun | 3751 | @end defun |
| 3750 | 3752 | ||
| 3751 | @defun copy-tree x &optional vecp | ||
| 3752 | This function returns a copy of the tree of cons cells @var{x}. | ||
| 3753 | @c FIXME? cl-copy-list is not an alias of copy-sequence. | ||
| 3754 | Unlike @code{copy-sequence} (and its alias @code{cl-copy-list}), | ||
| 3755 | which copies only along the @sc{cdr} direction, this function | ||
| 3756 | copies (recursively) along both the @sc{car} and the @sc{cdr} | ||
| 3757 | directions. If @var{x} is not a cons cell, the function simply | ||
| 3758 | returns @var{x} unchanged. If the optional @var{vecp} argument | ||
| 3759 | is true, this function copies vectors (recursively) as well as | ||
| 3760 | cons cells. | ||
| 3761 | @end defun | ||
| 3762 | |||
| 3763 | @defun cl-tree-equal x y @t{&key :test :test-not :key} | 3753 | @defun cl-tree-equal x y @t{&key :test :test-not :key} |
| 3764 | This function compares two trees of cons cells. If @var{x} and | 3754 | This function compares two trees of cons cells. If @var{x} and |
| 3765 | @var{y} are both cons cells, their @sc{car}s and @sc{cdr}s are | 3755 | @var{y} are both cons cells, their @sc{car}s and @sc{cdr}s are |
| @@ -3822,7 +3812,7 @@ This is a destructive version of @code{cl-sublis}. | |||
| 3822 | @section Lists as Sets | 3812 | @section Lists as Sets |
| 3823 | 3813 | ||
| 3824 | @noindent | 3814 | @noindent |
| 3825 | These functions perform operations on lists which represent sets | 3815 | These functions perform operations on lists that represent sets |
| 3826 | of elements. | 3816 | of elements. |
| 3827 | 3817 | ||
| 3828 | @defun cl-member item list @t{&key :test :test-not :key} | 3818 | @defun cl-member item list @t{&key :test :test-not :key} |
| @@ -3835,13 +3825,14 @@ are compared by @code{eql} by default; you can use the @code{:test}, | |||
| 3835 | 3825 | ||
| 3836 | The standard Emacs lisp function @code{member} uses @code{equal} for | 3826 | The standard Emacs lisp function @code{member} uses @code{equal} for |
| 3837 | comparisons; it is equivalent to @code{(cl-member @var{item} @var{list} | 3827 | comparisons; it is equivalent to @code{(cl-member @var{item} @var{list} |
| 3838 | :test 'equal)}. | 3828 | :test 'equal)}. With no keyword arguments, @code{cl-member} is |
| 3829 | equivalent to @code{memq}. | ||
| 3839 | @end defun | 3830 | @end defun |
| 3840 | 3831 | ||
| 3841 | @findex cl-member-if | 3832 | @findex cl-member-if |
| 3842 | @findex cl-member-if-not | 3833 | @findex cl-member-if-not |
| 3843 | The @code{cl-member-if} and @code{cl-member-if-not} functions | 3834 | The @code{cl-member-if} and @code{cl-member-if-not} functions |
| 3844 | analogously search for elements which satisfy a given predicate. | 3835 | analogously search for elements that satisfy a given predicate. |
| 3845 | 3836 | ||
| 3846 | @defun cl-tailp sublist list | 3837 | @defun cl-tailp sublist list |
| 3847 | This function returns @code{t} if @var{sublist} is a sublist of | 3838 | This function returns @code{t} if @var{sublist} is a sublist of |
| @@ -3860,11 +3851,11 @@ become part of the list. | |||
| 3860 | @end defun | 3851 | @end defun |
| 3861 | 3852 | ||
| 3862 | @defun cl-union list1 list2 @t{&key :test :test-not :key} | 3853 | @defun cl-union list1 list2 @t{&key :test :test-not :key} |
| 3863 | This function combines two lists which represent sets of items, | 3854 | This function combines two lists that represent sets of items, |
| 3864 | returning a list that represents the union of those two sets. | 3855 | returning a list that represents the union of those two sets. |
| 3865 | The result list will contain all items which appear in @var{list1} | 3856 | The resulting list contains all items that appear in @var{list1} |
| 3866 | or @var{list2}, and no others. If an item appears in both | 3857 | or @var{list2}, and no others. If an item appears in both |
| 3867 | @var{list1} and @var{list2} it will be copied only once. If | 3858 | @var{list1} and @var{list2} it is copied only once. If |
| 3868 | an item is duplicated in @var{list1} or @var{list2}, it is | 3859 | an item is duplicated in @var{list1} or @var{list2}, it is |
| 3869 | undefined whether or not that duplication will survive in the | 3860 | undefined whether or not that duplication will survive in the |
| 3870 | result list. The order of elements in the result list is also | 3861 | result list. The order of elements in the result list is also |
| @@ -3879,7 +3870,7 @@ it tries to reuse the storage of the argument lists if possible. | |||
| 3879 | @defun cl-intersection list1 list2 @t{&key :test :test-not :key} | 3870 | @defun cl-intersection list1 list2 @t{&key :test :test-not :key} |
| 3880 | This function computes the intersection of the sets represented | 3871 | This function computes the intersection of the sets represented |
| 3881 | by @var{list1} and @var{list2}. It returns the list of items | 3872 | by @var{list1} and @var{list2}. It returns the list of items |
| 3882 | which appear in both @var{list1} and @var{list2}. | 3873 | that appear in both @var{list1} and @var{list2}. |
| 3883 | @end defun | 3874 | @end defun |
| 3884 | 3875 | ||
| 3885 | @defun cl-nintersection list1 list2 @t{&key :test :test-not :key} | 3876 | @defun cl-nintersection list1 list2 @t{&key :test :test-not :key} |
| @@ -3929,7 +3920,7 @@ This function searches the association list @var{a-list} for an | |||
| 3929 | element whose @sc{car} matches (in the sense of @code{:test}, | 3920 | element whose @sc{car} matches (in the sense of @code{:test}, |
| 3930 | @code{:test-not}, and @code{:key}, or by comparison with @code{eql}) | 3921 | @code{:test-not}, and @code{:key}, or by comparison with @code{eql}) |
| 3931 | a given @var{item}. It returns the matching element, if any, | 3922 | a given @var{item}. It returns the matching element, if any, |
| 3932 | otherwise @code{nil}. It ignores elements of @var{a-list} which | 3923 | otherwise @code{nil}. It ignores elements of @var{a-list} that |
| 3933 | are not cons cells. (This corresponds to the behavior of | 3924 | are not cons cells. (This corresponds to the behavior of |
| 3934 | @code{assq} and @code{assoc} in Emacs Lisp; Common Lisp's | 3925 | @code{assq} and @code{assoc} in Emacs Lisp; Common Lisp's |
| 3935 | @code{assoc} ignores @code{nil}s but considers any other non-cons | 3926 | @code{assoc} ignores @code{nil}s but considers any other non-cons |
| @@ -3990,11 +3981,11 @@ are symbols. For example, | |||
| 3990 | @end example | 3981 | @end example |
| 3991 | 3982 | ||
| 3992 | @noindent | 3983 | @noindent |
| 3993 | defines a struct type called @code{person} which contains three | 3984 | defines a struct type called @code{person} that contains three |
| 3994 | slots. Given a @code{person} object @var{p}, you can access those | 3985 | slots. Given a @code{person} object @var{p}, you can access those |
| 3995 | slots by calling @code{(person-name @var{p})}, @code{(person-age @var{p})}, | 3986 | slots by calling @code{(person-name @var{p})}, @code{(person-age @var{p})}, |
| 3996 | and @code{(person-sex @var{p})}. You can also change these slots by | 3987 | and @code{(person-sex @var{p})}. You can also change these slots by |
| 3997 | using @code{setf} on any of these place forms: | 3988 | using @code{setf} on any of these place forms, for example: |
| 3998 | 3989 | ||
| 3999 | @example | 3990 | @example |
| 4000 | (cl-incf (person-age birthday-boy)) | 3991 | (cl-incf (person-age birthday-boy)) |
| @@ -4011,10 +4002,10 @@ Given a @code{person}, @code{(copy-person @var{p})} makes a new | |||
| 4011 | object of the same type whose slots are @code{eq} to those of @var{p}. | 4002 | object of the same type whose slots are @code{eq} to those of @var{p}. |
| 4012 | 4003 | ||
| 4013 | Given any Lisp object @var{x}, @code{(person-p @var{x})} returns | 4004 | Given any Lisp object @var{x}, @code{(person-p @var{x})} returns |
| 4014 | true if @var{x} looks like a @code{person}, false otherwise. (Again, | 4005 | true if @var{x} looks like a @code{person}, and false otherwise. (Again, |
| 4015 | in Common Lisp this predicate would be exact; in Emacs Lisp the | 4006 | in Common Lisp this predicate would be exact; in Emacs Lisp the |
| 4016 | best it can do is verify that @var{x} is a vector of the correct | 4007 | best it can do is verify that @var{x} is a vector of the correct |
| 4017 | length which starts with the correct tag symbol.) | 4008 | length that starts with the correct tag symbol.) |
| 4018 | 4009 | ||
| 4019 | Accessors like @code{person-name} normally check their arguments | 4010 | Accessors like @code{person-name} normally check their arguments |
| 4020 | (effectively using @code{person-p}) and signal an error if the | 4011 | (effectively using @code{person-p}) and signal an error if the |
| @@ -4051,7 +4042,7 @@ In general, @var{name} is either a name symbol or a list of a name | |||
| 4051 | symbol followed by any number of @dfn{struct options}; each @var{slot} | 4042 | symbol followed by any number of @dfn{struct options}; each @var{slot} |
| 4052 | is either a slot symbol or a list of the form @samp{(@var{slot-name} | 4043 | is either a slot symbol or a list of the form @samp{(@var{slot-name} |
| 4053 | @var{default-value} @var{slot-options}@dots{})}. The @var{default-value} | 4044 | @var{default-value} @var{slot-options}@dots{})}. The @var{default-value} |
| 4054 | is a Lisp form which is evaluated any time an instance of the | 4045 | is a Lisp form that is evaluated any time an instance of the |
| 4055 | structure type is created without specifying that slot's value. | 4046 | structure type is created without specifying that slot's value. |
| 4056 | 4047 | ||
| 4057 | Common Lisp defines several slot options, but the only one | 4048 | Common Lisp defines several slot options, but the only one |
| @@ -4109,11 +4100,11 @@ The argument names should match the slot names; each slot is | |||
| 4109 | initialized from the corresponding argument. Slots whose names | 4100 | initialized from the corresponding argument. Slots whose names |
| 4110 | do not appear in the argument list are initialized based on the | 4101 | do not appear in the argument list are initialized based on the |
| 4111 | @var{default-value} in their slot descriptor. Also, @code{&optional} | 4102 | @var{default-value} in their slot descriptor. Also, @code{&optional} |
| 4112 | and @code{&key} arguments which don't specify defaults take their | 4103 | and @code{&key} arguments that don't specify defaults take their |
| 4113 | defaults from the slot descriptor. It is valid to include arguments | 4104 | defaults from the slot descriptor. It is valid to include arguments |
| 4114 | which don't correspond to slot names; these are useful if they are | 4105 | that don't correspond to slot names; these are useful if they are |
| 4115 | referred to in the defaults for optional, keyword, or @code{&aux} | 4106 | referred to in the defaults for optional, keyword, or @code{&aux} |
| 4116 | arguments which @emph{do} correspond to slots. | 4107 | arguments that @emph{do} correspond to slots. |
| 4117 | 4108 | ||
| 4118 | You can specify any number of full-format @code{:constructor} | 4109 | You can specify any number of full-format @code{:constructor} |
| 4119 | options on a structure. The default constructor is still generated | 4110 | options on a structure. The default constructor is still generated |
| @@ -4154,7 +4145,7 @@ means not to generate a copier function. (In this implementation, | |||
| 4154 | all copier functions are simply synonyms for @code{copy-sequence}.) | 4145 | all copier functions are simply synonyms for @code{copy-sequence}.) |
| 4155 | 4146 | ||
| 4156 | @item :predicate | 4147 | @item :predicate |
| 4157 | The argument is an alternate name for the predicate which recognizes | 4148 | The argument is an alternate name for the predicate that recognizes |
| 4158 | objects of this type. The default is @code{@var{name}-p}. @code{nil} | 4149 | objects of this type. The default is @code{@var{name}-p}. @code{nil} |
| 4159 | means not to generate a predicate function. (If the @code{:type} | 4150 | means not to generate a predicate function. (If the @code{:type} |
| 4160 | option is used without the @code{:named} option, no predicate is | 4151 | option is used without the @code{:named} option, no predicate is |
| @@ -4214,7 +4205,7 @@ work on astronauts just like other people. | |||
| 4214 | 4205 | ||
| 4215 | @item :print-function | 4206 | @item :print-function |
| 4216 | In full Common Lisp, this option allows you to specify a function | 4207 | In full Common Lisp, this option allows you to specify a function |
| 4217 | which is called to print an instance of the structure type. The | 4208 | that is called to print an instance of the structure type. The |
| 4218 | Emacs Lisp system offers no hooks into the Lisp printer which would | 4209 | Emacs Lisp system offers no hooks into the Lisp printer which would |
| 4219 | allow for such a feature, so this package simply ignores | 4210 | allow for such a feature, so this package simply ignores |
| 4220 | @code{:print-function}. | 4211 | @code{:print-function}. |
| @@ -4391,7 +4382,7 @@ You can find out how a macro expands by using the | |||
| 4391 | This function takes a single Lisp form as an argument and inserts | 4382 | This function takes a single Lisp form as an argument and inserts |
| 4392 | a nicely formatted copy of it in the current buffer (which must be | 4383 | a nicely formatted copy of it in the current buffer (which must be |
| 4393 | in Lisp mode so that indentation works properly). It also expands | 4384 | in Lisp mode so that indentation works properly). It also expands |
| 4394 | all Lisp macros which appear in the form. The easiest way to use | 4385 | all Lisp macros that appear in the form. The easiest way to use |
| 4395 | this function is to go to the @file{*scratch*} buffer and type, say, | 4386 | this function is to go to the @file{*scratch*} buffer and type, say, |
| 4396 | 4387 | ||
| 4397 | @example | 4388 | @example |
| @@ -4400,7 +4391,7 @@ this function is to go to the @file{*scratch*} buffer and type, say, | |||
| 4400 | 4391 | ||
| 4401 | @noindent | 4392 | @noindent |
| 4402 | and type @kbd{C-x C-e} immediately after the closing parenthesis; | 4393 | and type @kbd{C-x C-e} immediately after the closing parenthesis; |
| 4403 | the expansion | 4394 | an expansion similar to: |
| 4404 | 4395 | ||
| 4405 | @example | 4396 | @example |
| 4406 | (cl-block nil | 4397 | (cl-block nil |
| @@ -4421,7 +4412,11 @@ variable @code{G1004} was created by @code{cl-gensym}.) | |||
| 4421 | If the optional argument @var{full} is true, then @emph{all} | 4412 | If the optional argument @var{full} is true, then @emph{all} |
| 4422 | macros are expanded, including @code{cl-block}, @code{cl-eval-when}, | 4413 | macros are expanded, including @code{cl-block}, @code{cl-eval-when}, |
| 4423 | and compiler macros. Expansion is done as if @var{form} were | 4414 | and compiler macros. Expansion is done as if @var{form} were |
| 4424 | a top-level form in a file being compiled. For example, | 4415 | a top-level form in a file being compiled. |
| 4416 | |||
| 4417 | @c FIXME none of these examples are still applicable. | ||
| 4418 | @ignore | ||
| 4419 | For example, | ||
| 4425 | 4420 | ||
| 4426 | @example | 4421 | @example |
| 4427 | (cl-prettyexpand '(cl-pushnew 'x list)) | 4422 | (cl-prettyexpand '(cl-pushnew 'x list)) |
| @@ -4431,16 +4426,12 @@ a top-level form in a file being compiled. For example, | |||
| 4431 | (cl-prettyexpand '(caddr (cl-member 'a list)) t) | 4426 | (cl-prettyexpand '(caddr (cl-member 'a list)) t) |
| 4432 | @print{} (car (cdr (cdr (memq 'a list)))) | 4427 | @print{} (car (cdr (cdr (memq 'a list)))) |
| 4433 | @end example | 4428 | @end example |
| 4429 | @end ignore | ||
| 4434 | 4430 | ||
| 4435 | Note that @code{cl-adjoin}, @code{cl-caddr}, and @code{cl-member} all | 4431 | Note that @code{cl-adjoin}, @code{cl-caddr}, and @code{cl-member} all |
| 4436 | have built-in compiler macros to optimize them in common cases. | 4432 | have built-in compiler macros to optimize them in common cases. |
| 4437 | @end defun | 4433 | @end defun |
| 4438 | 4434 | ||
| 4439 | @ifinfo | ||
| 4440 | @example | ||
| 4441 | |||
| 4442 | @end example | ||
| 4443 | @end ifinfo | ||
| 4444 | @appendixsec Error Checking | 4435 | @appendixsec Error Checking |
| 4445 | 4436 | ||
| 4446 | @noindent | 4437 | @noindent |
| @@ -4450,7 +4441,7 @@ where substantial gains were possible at the expense of marginal | |||
| 4450 | incompatibility. | 4441 | incompatibility. |
| 4451 | 4442 | ||
| 4452 | The Common Lisp standard (as embodied in Steele's book) uses the | 4443 | The Common Lisp standard (as embodied in Steele's book) uses the |
| 4453 | phrase ``it is an error if'' to indicate a situation which is not | 4444 | phrase ``it is an error if'' to indicate a situation that is not |
| 4454 | supposed to arise in complying programs; implementations are strongly | 4445 | supposed to arise in complying programs; implementations are strongly |
| 4455 | encouraged but not required to signal an error in these situations. | 4446 | encouraged but not required to signal an error in these situations. |
| 4456 | This package sometimes omits such error checking in the interest of | 4447 | This package sometimes omits such error checking in the interest of |
| @@ -4472,20 +4463,16 @@ you can use @code{&allow-other-keys} to omit this check. Functions | |||
| 4472 | defined in this package such as @code{cl-find} and @code{cl-member} | 4463 | defined in this package such as @code{cl-find} and @code{cl-member} |
| 4473 | do check their keyword arguments for validity. | 4464 | do check their keyword arguments for validity. |
| 4474 | 4465 | ||
| 4475 | @ifinfo | 4466 | @appendixsec Compiler Optimizations |
| 4476 | @example | ||
| 4477 | |||
| 4478 | @end example | ||
| 4479 | @end ifinfo | ||
| 4480 | @appendixsec Optimizing Compiler | ||
| 4481 | 4467 | ||
| 4482 | @noindent | 4468 | @noindent |
| 4483 | Use of the optimizing Emacs compiler is highly recommended; many of the Common | 4469 | Changing the value of @code{byte-optimize} from the default @code{t} |
| 4470 | is highly discouraged; many of the Common | ||
| 4484 | Lisp macros emit | 4471 | Lisp macros emit |
| 4485 | code which can be improved by optimization. In particular, | 4472 | code that can be improved by optimization. In particular, |
| 4486 | @code{cl-block}s (whether explicit or implicit in constructs like | 4473 | @code{cl-block}s (whether explicit or implicit in constructs like |
| 4487 | @code{cl-defun} and @code{cl-loop}) carry a fair run-time penalty; the | 4474 | @code{cl-defun} and @code{cl-loop}) carry a fair run-time penalty; the |
| 4488 | byte-compiler removes @code{cl-block}s which are not actually | 4475 | byte-compiler removes @code{cl-block}s that are not actually |
| 4489 | referenced by @code{cl-return} or @code{cl-return-from} inside the block. | 4476 | referenced by @code{cl-return} or @code{cl-return-from} inside the block. |
| 4490 | 4477 | ||
| 4491 | @node Common Lisp Compatibility | 4478 | @node Common Lisp Compatibility |