aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/ChangeLog6
-rw-r--r--doc/lispref/elisp.texi1
-rw-r--r--doc/lispref/lists.texi8
-rw-r--r--doc/lispref/variables.texi103
-rw-r--r--doc/misc/ChangeLog10
-rw-r--r--doc/misc/cl.texi235
6 files changed, 209 insertions, 154 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 03922f2c02f..aea26248452 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,5 +1,11 @@
12012-10-27 Glenn Morris <rgm@gnu.org> 12012-10-27 Glenn Morris <rgm@gnu.org>
2 2
3 * variables.texi (Generalized Variables): New section,
4 adapted from misc/cl.texi.
5 * elisp.texi (Top): Add Generalized Variables to menu.
6 * lists.texi (List Elements, List Variables):
7 Mention generalized variables.
8
3 * lists.texi (List Elements): Typo fix. 9 * lists.texi (List Elements): Typo fix.
4 10
52012-10-27 Chong Yidong <cyd@gnu.org> 112012-10-27 Chong Yidong <cyd@gnu.org>
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 1d1dab8faac..06a2ebfcaf8 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -486,6 +486,7 @@ Variables
486* Variable Aliases:: Variables that are aliases for other variables. 486* Variable Aliases:: Variables that are aliases for other variables.
487* Variables with Restricted Values:: Non-constant variables whose value can 487* Variables with Restricted Values:: Non-constant variables whose value can
488 @emph{not} be an arbitrary Lisp object. 488 @emph{not} be an arbitrary Lisp object.
489* Generalized Variables:: Extending the concept of variables.
489 490
490Scoping Rules for Variable Bindings 491Scoping Rules for Variable Bindings
491 492
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi
index eaef8cc1f8a..09948caaa13 100644
--- a/doc/lispref/lists.texi
+++ b/doc/lispref/lists.texi
@@ -236,6 +236,10 @@ This is in contrast to @code{cdr}, which signals an error if
236@defmac pop listname 236@defmac pop listname
237This macro is a way of examining the @sc{car} of a list, 237This macro is a way of examining the @sc{car} of a list,
238and taking it off the list, all at once. 238and taking it off the list, all at once.
239@c FIXME I don't think is a particularly good way to do it,
240@c but generalized variables have not been introduced yet.
241(In fact, this macro can act on generalized variables, not just lists.
242@xref{Generalized Variables}.)
239 243
240It operates on the list which is stored in the symbol @var{listname}. 244It operates on the list which is stored in the symbol @var{listname}.
241It removes this element from the list by setting @var{listname} 245It removes this element from the list by setting @var{listname}
@@ -682,6 +686,10 @@ to modify a list which is stored in a variable.
682@defmac push newelt listname 686@defmac push newelt listname
683This macro provides an alternative way to write 687This macro provides an alternative way to write
684@code{(setq @var{listname} (cons @var{newelt} @var{listname}))}. 688@code{(setq @var{listname} (cons @var{newelt} @var{listname}))}.
689@c FIXME I don't think is a particularly good way to do it,
690@c but generalized variables have not been introduced yet.
691(In fact, this macro can act on generalized variables, not just lists.
692@xref{Generalized Variables}.)
685 693
686@example 694@example
687(setq l '(a b)) 695(setq l '(a b))
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 1c0abcb8e66..1ffb1f7ffcb 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -41,6 +41,7 @@ representing the variable.
41* Variable Aliases:: Variables that are aliases for other variables. 41* Variable Aliases:: Variables that are aliases for other variables.
42* Variables with Restricted Values:: Non-constant variables whose value can 42* Variables with Restricted Values:: Non-constant variables whose value can
43 @emph{not} be an arbitrary Lisp object. 43 @emph{not} be an arbitrary Lisp object.
44* Generalized Variables:: Extending the concept of variables.
44@end menu 45@end menu
45 46
46@node Global Variables 47@node Global Variables
@@ -1946,3 +1947,105 @@ Attempting to assign them any other value will result in an error:
1946(setq undo-limit 1000.0) 1947(setq undo-limit 1000.0)
1947@error{} Wrong type argument: integerp, 1000.0 1948@error{} Wrong type argument: integerp, 1000.0
1948@end example 1949@end example
1950
1951@c FIXME? Not sure this is the right place for this section.
1952@node Generalized Variables
1953@section Generalized Variables
1954
1955A @dfn{generalized variable} or @dfn{place form} is one of the many places
1956in Lisp memory where values can be stored. The simplest place form is
1957a regular Lisp variable. But the @sc{car}s and @sc{cdr}s of lists, elements
1958of arrays, properties of symbols, and many other locations are also
1959places where Lisp values are stored.
1960
1961@c FIXME? Not sure this is a useful analogy...
1962Generalized variables are analogous to ``lvalues'' in the C
1963language, where @samp{x = a[i]} gets an element from an array
1964and @samp{a[i] = x} stores an element using the same notation.
1965Just as certain forms like @code{a[i]} can be lvalues in C, there
1966is a set of forms that can be generalized variables in Lisp.
1967
1968The @code{setf} macro is the most basic way to operate on generalized
1969variables. The @code{setf} form is like @code{setq}, except that it
1970accepts arbitrary place forms on the left side rather than just
1971symbols. For example, @code{(setf (car a) b)} sets the car of
1972@code{a} to @code{b}, doing the same operation as @code{(setcar a b)},
1973but without having to remember two separate functions for setting and
1974accessing every type of place.
1975
1976@defmac setf [place form]@dots{}
1977This macro evaluates @var{form} and stores it in @var{place}, which
1978must be a valid generalized variable form. If there are several
1979@var{place} and @var{form} pairs, the assignments are done sequentially
1980just as with @code{setq}. @code{setf} returns the value of the last
1981@var{form}.
1982@end defmac
1983
1984The following Lisp forms will work as generalized variables, and
1985so may appear in the @var{place} argument of @code{setf}:
1986
1987@itemize
1988@item
1989A symbol naming a variable. In other words, @code{(setf x y)} is
1990exactly equivalent to @code{(setq x y)}, and @code{setq} itself is
1991strictly speaking redundant given that @code{setf} exists. Many
1992programmers continue to prefer @code{setq} for setting simple
1993variables, though, purely for stylistic or historical reasons.
1994The macro @code{(setf x y)} actually expands to @code{(setq x y)},
1995so there is no performance penalty for using it in compiled code.
1996
1997@item
1998A call to any of the following standard Lisp functions:
1999
2000@smallexample
2001car cdr nth nthcdr
2002caar cadr cdar cddr
2003aref elt get gethash
2004symbol-function symbol-value symbol-plist
2005@end smallexample
2006
2007@item
2008The following Emacs-specific functions are also @code{setf}-able:
2009
2010@smallexample
2011default-value process-get
2012frame-parameter process-sentinel
2013terminal-parameter window-buffer
2014keymap-parent window-display-table
2015match-data window-dedicated-p
2016overlay-get window-hscroll
2017overlay-start window-parameter
2018overlay-end window-point
2019process-buffer window-start
2020process-filter
2021@end smallexample
2022@end itemize
2023
2024@noindent
2025Using any forms other than these in the @var{place} argument to
2026@code{setf} will signal an error.
2027
2028Note that for @code{nthcdr} and @code{getf}, the list argument
2029of the function must itself be a valid @var{place} form. For
2030example, @code{(setf (nthcdr 0 foo) 7)} will set @code{foo} itself
2031to 7.
2032@c The use of @code{nthcdr} as a @var{place} form is an extension
2033@c to standard Common Lisp.
2034
2035@c FIXME I don't think is a particularly good way to do it,
2036@c but these macros are introduced before gvs are.
2037The macros @code{push} (@pxref{List Variables}) and @code{pop}
2038(@pxref{List Elements}) can manipulate generalized variables,
2039not just lists. @code{(pop @var{place})} removes and returns the first
2040element of the list stored in @var{place}. It is analogous to
2041@code{(prog1 (car @var{place}) (setf @var{place} (cdr @var{place})))},
2042except that it takes care to evaluate all subforms only once.
2043@code{(push @var{x} @var{place})} inserts @var{x} at the front of
2044the list stored in @var{place}. It is analogous to @code{(setf
2045@var{place} (cons @var{x} @var{place}))}, except for evaluation of the
2046subforms. Note that @code{push} and @code{pop} on an @code{nthcdr}
2047place can be used to insert or delete at any position in a list.
2048
2049The @file{cl-lib} library defines various extensions for generalized
2050variables, including additional @code{setf} places.
2051@xref{Generalized Variables,,, cl, Common Lisp Extensions}.
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index a0cfd675f0a..d447b0ca1ff 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,13 @@
12012-10-27 Glenn Morris <rgm@gnu.org>
2
3 * cl.texi (Control Structure): Update for setf now being in core.
4 (Setf Extensions): Rename from Basic Setf. Move much of the
5 former content to lispref/variables.texi.
6 (Modify Macros): Move pop, push details to lispref/variables.texi.
7 (Customizing Setf): Copyedits for setf etc being in core.
8 (Modify Macros, Efficiency Concerns, Porting Common Lisp):
9 Further namespaces updates.
10
12012-10-26 Bastien Guerry <bzg@gnu.org> 112012-10-26 Bastien Guerry <bzg@gnu.org>
2 12
3 * org.texi (Installation): Update the link to Org's ELPA. Also 13 * org.texi (Installation): Update the link to Org's ELPA. Also
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 9200958a1b5..aba3f244012 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -57,7 +57,7 @@ developing GNU and promoting software freedom.''
57* Overview:: Basics, usage, etc. 57* Overview:: Basics, usage, etc.
58* Program Structure:: Arglists, @code{cl-eval-when}, @code{defalias}. 58* Program Structure:: Arglists, @code{cl-eval-when}, @code{defalias}.
59* Predicates:: @code{cl-typep} and @code{cl-equalp}. 59* Predicates:: @code{cl-typep} and @code{cl-equalp}.
60* Control Structure:: @code{setf}, @code{cl-do}, @code{cl-loop}, etc. 60* Control Structure:: @code{cl-do}, @code{cl-loop}, etc.
61* Macros:: Destructuring, @code{cl-define-compiler-macro}. 61* Macros:: Destructuring, @code{cl-define-compiler-macro}.
62* Declarations:: @code{cl-proclaim}, @code{cl-declare}, etc. 62* Declarations:: @code{cl-proclaim}, @code{cl-declare}, etc.
63* Symbols:: Property lists, @code{cl-gensym}. 63* Symbols:: Property lists, @code{cl-gensym}.
@@ -801,17 +801,16 @@ In Emacs, use @code{memq} (or @code{cl-member}) and @code{assq} (or
801 801
802@noindent 802@noindent
803The features described in the following sections implement 803The features described in the following sections implement
804various advanced control structures, including the powerful 804various advanced control structures, including extensions to the
805@c FIXME setf is now in gv.el, not cl. 805standard @code{setf} facility, and a number of looping and conditional
806@code{setf} facility and a number of looping and conditional
807constructs. 806constructs.
808 807
809@c FIXME setf, push are standard now. 808@c FIXME
810@c lexical-let is obsolete; flet is not cl-flet. 809@c lexical-let is obsolete; flet is not cl-flet.
811@c values is not cl-values. 810@c values is not cl-values.
812@menu 811@menu
813* Assignment:: The @code{cl-psetq} form. 812* Assignment:: The @code{cl-psetq} form.
814* Generalized Variables:: @code{setf}, @code{cl-incf}, @code{push}, etc. 813* Generalized Variables:: Extensions to generalized variables.
815* Variable Bindings:: @code{cl-progv}, @code{lexical-let}, @code{flet}, @code{cl-macrolet}. 814* Variable Bindings:: @code{cl-progv}, @code{lexical-let}, @code{flet}, @code{cl-macrolet}.
816* Conditionals:: @code{cl-case}, @code{cl-typecase}. 815* Conditionals:: @code{cl-case}, @code{cl-typecase}.
817* Blocks and Exits:: @code{cl-block}, @code{cl-return}, @code{cl-return-from}. 816* Blocks and Exits:: @code{cl-block}, @code{cl-return}, @code{cl-return-from}.
@@ -857,130 +856,74 @@ provides an even more convenient way to swap two variables;
857@code{cl-psetq} always returns @code{nil}. 856@code{cl-psetq} always returns @code{nil}.
858@end defspec 857@end defspec
859 858
860@c FIXME now in gv.el.
861@node Generalized Variables 859@node Generalized Variables
862@section Generalized Variables 860@section Generalized Variables
863 861
864@noindent 862A @dfn{generalized variable} or @dfn{place form} is one of the many
865A ``generalized variable'' or ``place form'' is one of the many places 863places in Lisp memory where values can be stored. The simplest place
866in Lisp memory where values can be stored. The simplest place form is 864form is a regular Lisp variable. But the cars and cdrs of lists,
867a regular Lisp variable. But the cars and cdrs of lists, elements 865elements of arrays, properties of symbols, and many other locations
868of arrays, properties of symbols, and many other locations are also 866are also places where Lisp values are stored. For basic information,
869places where Lisp values are stored. 867@pxref{Generalized Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
870 868This package provides several additional features related to
871The @code{setf} form is like @code{setq}, except that it accepts 869generalized variables.
872arbitrary place forms on the left side rather than just
873symbols. For example, @code{(setf (car a) b)} sets the car of
874@code{a} to @code{b}, doing the same operation as @code{(setcar a b)}
875but without having to remember two separate functions for setting
876and accessing every type of place.
877
878Generalized variables are analogous to ``lvalues'' in the C
879language, where @samp{x = a[i]} gets an element from an array
880and @samp{a[i] = x} stores an element using the same notation.
881Just as certain forms like @code{a[i]} can be lvalues in C, there
882is a set of forms that can be generalized variables in Lisp.
883 870
884@menu 871@menu
885* Basic Setf:: @code{setf} and place forms. 872* Setf Extensions:: Additional @code{setf} places.
886* Modify Macros:: @code{cl-incf}, @code{push}, @code{cl-rotatef}, @code{letf}, @code{cl-callf}, etc. 873* Modify Macros:: @code{cl-incf}, @code{cl-rotatef}, @code{letf}, @code{cl-callf}, etc.
887* Customizing Setf:: @code{define-modify-macro}, @code{defsetf}, @code{define-setf-method}. 874* Customizing Setf:: @code{define-modify-macro}, @code{defsetf}, @code{define-setf-method}.
888@end menu 875@end menu
889 876
890@node Basic Setf 877@node Setf Extensions
891@subsection Basic Setf 878@subsection Setf Extensions
892
893@noindent
894The @code{setf} macro is the most basic way to operate on generalized
895variables.
896
897@defspec setf [place form]@dots{}
898This macro evaluates @var{form} and stores it in @var{place}, which
899must be a valid generalized variable form. If there are several
900@var{place} and @var{form} pairs, the assignments are done sequentially
901just as with @code{setq}. @code{setf} returns the value of the last
902@var{form}.
903
904The following Lisp forms will work as generalized variables, and
905so may appear in the @var{place} argument of @code{setf}:
906 879
907@itemize @bullet 880Several standard (e.g. @code{car}) and Emacs-specific
908@item 881(e.g. @code{window-point}) Lisp functions are @code{setf}-able by default.
909A symbol naming a variable. In other words, @code{(setf x y)} is 882This package defines @code{setf} handlers for several additional functions:
910exactly equivalent to @code{(setq x y)}, and @code{setq} itself is
911strictly speaking redundant now that @code{setf} exists. Many
912programmers continue to prefer @code{setq} for setting simple
913variables, though, purely for stylistic or historical reasons.
914The macro @code{(setf x y)} actually expands to @code{(setq x y)},
915so there is no performance penalty for using it in compiled code.
916 883
884@itemize
917@item 885@item
918A call to any of the following Lisp functions: 886Functions from @code{CL} itself:
919
920@smallexample 887@smallexample
921car cdr caar .. cddddr 888cl-caaar .. cl-cddddr cl-first .. cl-tenth
922nth rest first .. tenth 889cl-rest cl-get cl-getf cl-subseq
923aref elt nthcdr
924symbol-function symbol-value symbol-plist
925get get* getf
926gethash subseq
927@end smallexample 890@end smallexample
928 891
929@noindent
930Note that for @code{nthcdr} and @code{getf}, the list argument
931of the function must itself be a valid @var{place} form. For
932example, @code{(setf (nthcdr 0 foo) 7)} will set @code{foo} itself
933to 7. Note that @code{push} and @code{pop} on an @code{nthcdr}
934place can be used to insert or delete at any position in a list.
935The use of @code{nthcdr} as a @var{place} form is an extension
936to standard Common Lisp.
937
938@item 892@item
939The following Emacs-specific functions are also @code{setf}-able. 893General Emacs Lisp functions:
940
941@smallexample 894@smallexample
942buffer-file-name marker-position 895buffer-file-name getenv
943buffer-modified-p match-data 896buffer-modified-p global-key-binding
944buffer-name mouse-position 897buffer-name local-key-binding
945buffer-string overlay-end 898buffer-string mark
946buffer-substring overlay-get 899buffer-substring mark-marker
947current-buffer overlay-start 900current-buffer marker-position
948current-case-table point 901current-case-table mouse-position
949current-column point-marker 902current-column point
950current-global-map point-max 903current-global-map point-marker
951current-input-mode point-min 904current-input-mode point-max
952current-local-map process-buffer 905current-local-map point-min
953current-window-configuration process-filter 906current-window-configuration read-mouse-position
954default-file-modes process-sentinel 907default-file-modes screen-height
955default-value read-mouse-position 908documentation-property screen-width
956documentation-property screen-height 909face-background selected-window
957extent-data screen-menubar 910face-background-pixmap selected-screen
958extent-end-position screen-width 911face-font selected-frame
959extent-start-position selected-window 912face-foreground standard-case-table
960face-background selected-screen 913face-underline-p syntax-table
961face-background-pixmap selected-frame 914file-modes visited-file-modtime
962face-font standard-case-table 915frame-height window-height
963face-foreground syntax-table 916frame-parameters window-width
964face-underline-p window-buffer 917frame-visible-p x-get-secondary-selection
965file-modes window-dedicated-p 918frame-width x-get-selection
966frame-height window-display-table 919get-register
967frame-parameters window-height
968frame-visible-p window-hscroll
969frame-width window-point
970get-register window-start
971getenv window-width
972global-key-binding x-get-secondary-selection
973keymap-parent x-get-selection
974local-key-binding
975mark
976mark-marker
977@end smallexample 920@end smallexample
978 921
979Most of these have directly corresponding ``set'' functions, like 922Most of these have directly corresponding ``set'' functions, like
980@code{use-local-map} for @code{current-local-map}, or @code{goto-char} 923@code{use-local-map} for @code{current-local-map}, or @code{goto-char}
981for @code{point}. A few, like @code{point-min}, expand to longer 924for @code{point}. A few, like @code{point-min}, expand to longer
982sequences of code when they are @code{setf}'d (@code{(narrow-to-region 925sequences of code when they are used with @code{setf}
983x (point-max))} in this case). 926(@code{(narrow-to-region x (point-max))} in this case).
984 927
985@item 928@item
986A call of the form @code{(substring @var{subplace} @var{n} [@var{m}])}, 929A call of the form @code{(substring @var{subplace} @var{n} [@var{m}])},
@@ -1007,6 +950,8 @@ a
1007The generalized variable @code{buffer-substring}, listed above, 950The generalized variable @code{buffer-substring}, listed above,
1008also works in this way by replacing a portion of the current buffer. 951also works in this way by replacing a portion of the current buffer.
1009 952
953@c FIXME? Also `eq'? (see cl-lib.el)
954
1010@item 955@item
1011A call of the form @code{(apply '@var{func} @dots{})} or 956A call of the form @code{(apply '@var{func} @dots{})} or
1012@code{(apply (function @var{func}) @dots{})}, where @var{func} 957@code{(apply (function @var{func}) @dots{})}, where @var{func}
@@ -1025,9 +970,9 @@ Any form for which a @code{defsetf} or @code{define-setf-method}
1025has been made. 970has been made.
1026@end itemize 971@end itemize
1027 972
1028Using any forms other than these in the @var{place} argument to 973@c FIXME should this be in lispref? It seems self-evident.
1029@code{setf} will signal an error. 974@c Contrast with the cl-incf example later on.
1030 975@c Here it really only serves as a constrast to wrong-order.
1031The @code{setf} macro takes care to evaluate all subforms in 976The @code{setf} macro takes care to evaluate all subforms in
1032the proper left-to-right order; for example, 977the proper left-to-right order; for example,
1033 978
@@ -1056,15 +1001,14 @@ will be preserved. Adapting an example from Steele, given
1056the form @code{(setf (wrong-order @var{a} @var{b}) 17)} will 1001the form @code{(setf (wrong-order @var{a} @var{b}) 17)} will
1057evaluate @var{b} first, then @var{a}, just as in an actual call 1002evaluate @var{b} first, then @var{a}, just as in an actual call
1058to @code{wrong-order}. 1003to @code{wrong-order}.
1059@end defspec
1060 1004
1061@node Modify Macros 1005@node Modify Macros
1062@subsection Modify Macros 1006@subsection Modify Macros
1063 1007
1064@noindent 1008@noindent
1065This package defines a number of other macros besides @code{setf} 1009This package defines a number of macros that operate on generalized
1066that operate on generalized variables. Many are interesting and 1010variables. Many are interesting and useful even when the @var{place}
1067useful even when the @var{place} is just a variable name. 1011is just a variable name.
1068 1012
1069@defspec cl-psetf [place form]@dots{} 1013@defspec cl-psetf [place form]@dots{}
1070This macro is to @code{setf} what @code{cl-psetq} is to @code{setq}: 1014This macro is to @code{setf} what @code{cl-psetq} is to @code{setq}:
@@ -1080,8 +1024,8 @@ by @var{x} if specified. The incremented value is returned. For
1080example, @code{(cl-incf i)} is equivalent to @code{(setq i (1+ i))}, and 1024example, @code{(cl-incf i)} is equivalent to @code{(setq i (1+ i))}, and
1081@code{(cl-incf (car x) 2)} is equivalent to @code{(setcar x (+ (car x) 2))}. 1025@code{(cl-incf (car x) 2)} is equivalent to @code{(setcar x (+ (car x) 2))}.
1082 1026
1083Once again, care is taken to preserve the ``apparent'' order of 1027As with @code{setf}, care is taken to preserve the ``apparent'' order
1084evaluation. For example, 1028of evaluation. For example,
1085 1029
1086@example 1030@example
1087(cl-incf (aref vec (cl-incf i))) 1031(cl-incf (aref vec (cl-incf i)))
@@ -1120,21 +1064,6 @@ This macro decrements the number stored in @var{place} by one, or
1120by @var{x} if specified. 1064by @var{x} if specified.
1121@end defspec 1065@end defspec
1122 1066
1123@c FIXME move to lispref, add generalized variables.
1124@defspec pop place
1125This macro removes and returns the first element of the list stored
1126in @var{place}. It is analogous to @code{(prog1 (car @var{place})
1127(setf @var{place} (cdr @var{place})))}, except that it takes care
1128to evaluate all subforms only once.
1129@end defspec
1130
1131@c FIXME move to lispref, add generalized variables.
1132@defspec push x place
1133This macro inserts @var{x} at the front of the list stored in
1134@var{place}. It is analogous to @code{(setf @var{place} (cons
1135@var{x} @var{place}))}, except for evaluation of the subforms.
1136@end defspec
1137
1138@defspec cl-pushnew x place @t{&key :test :test-not :key} 1067@defspec cl-pushnew x place @t{&key :test :test-not :key}
1139This macro inserts @var{x} at the front of the list stored in 1068This macro inserts @var{x} at the front of the list stored in
1140@var{place}, but only if @var{x} was not @code{eql} to any 1069@var{place}, but only if @var{x} was not @code{eql} to any
@@ -1143,19 +1072,19 @@ are interpreted in the same way as for @code{cl-adjoin}.
1143@xref{Lists as Sets}. 1072@xref{Lists as Sets}.
1144@end defspec 1073@end defspec
1145 1074
1146@defspec shiftf place@dots{} newvalue 1075@defspec cl-shiftf place@dots{} newvalue
1147This macro shifts the @var{place}s left by one, shifting in the 1076This macro shifts the @var{place}s left by one, shifting in the
1148value of @var{newvalue} (which may be any Lisp expression, not just 1077value of @var{newvalue} (which may be any Lisp expression, not just
1149a generalized variable), and returning the value shifted out of 1078a generalized variable), and returning the value shifted out of
1150the first @var{place}. Thus, @code{(shiftf @var{a} @var{b} @var{c} 1079the first @var{place}. Thus, @code{(cl-shiftf @var{a} @var{b} @var{c}
1151@var{d})} is equivalent to 1080@var{d})} is equivalent to
1152 1081
1153@example 1082@example
1154(prog1 1083(prog1
1155 @var{a} 1084 @var{a}
1156 (psetf @var{a} @var{b} 1085 (cl-psetf @var{a} @var{b}
1157 @var{b} @var{c} 1086 @var{b} @var{c}
1158 @var{c} @var{d})) 1087 @var{c} @var{d}))
1159@end example 1088@end example
1160 1089
1161@noindent 1090@noindent
@@ -1168,10 +1097,10 @@ This macro rotates the @var{place}s left by one in circular fashion.
1168Thus, @code{(cl-rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to 1097Thus, @code{(cl-rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to
1169 1098
1170@example 1099@example
1171(psetf @var{a} @var{b} 1100(cl-psetf @var{a} @var{b}
1172 @var{b} @var{c} 1101 @var{b} @var{c}
1173 @var{c} @var{d} 1102 @var{c} @var{d}
1174 @var{d} @var{a}) 1103 @var{d} @var{a})
1175@end example 1104@end example
1176 1105
1177@noindent 1106@noindent
@@ -1318,9 +1247,8 @@ Most of the modify macros defined by Common Lisp do not exactly
1318follow the pattern of @code{define-modify-macro}. For example, 1247follow the pattern of @code{define-modify-macro}. For example,
1319@code{push} takes its arguments in the wrong order, and @code{pop} 1248@code{push} takes its arguments in the wrong order, and @code{pop}
1320is completely irregular. You can define these macros ``by hand'' 1249is completely irregular. You can define these macros ``by hand''
1321using @code{get-setf-method}, or consult the source file 1250using @code{get-setf-method}, or consult the source
1322@file{cl-macs.el} to see how to use the internal @code{setf} 1251to see how to use the internal @code{setf} building blocks.
1323building blocks.
1324@end defspec 1252@end defspec
1325 1253
1326@defspec defsetf access-fn update-fn 1254@defspec defsetf access-fn update-fn
@@ -4708,32 +4636,31 @@ user to modify @var{place}.
4708 4636
4709@noindent 4637@noindent
4710Many of the advanced features of this package, such as @code{cl-defun}, 4638Many of the advanced features of this package, such as @code{cl-defun},
4711@code{cl-loop}, and @code{setf}, are implemented as Lisp macros. In 4639@code{cl-loop}, etc., are implemented as Lisp macros. In
4712byte-compiled code, these complex notations will be expanded into 4640byte-compiled code, these complex notations will be expanded into
4713equivalent Lisp code which is simple and efficient. For example, 4641equivalent Lisp code which is simple and efficient. For example,
4714the forms 4642the form
4715 4643
4716@example 4644@example
4717(cl-incf i n) 4645(cl-incf i n)
4718(push x (car p))
4719@end example 4646@end example
4720 4647
4721@noindent 4648@noindent
4722are expanded at compile-time to the Lisp forms 4649is expanded at compile-time to the Lisp form
4723 4650
4724@example 4651@example
4725(setq i (+ i n)) 4652(setq i (+ i n))
4726(setcar p (cons x (car p)))
4727@end example 4653@end example
4728 4654
4729@noindent 4655@noindent
4730which are the most efficient ways of doing these respective operations 4656which is the most efficient ways of doing this operation
4731in Lisp. Thus, there is no performance penalty for using the more 4657in Lisp. Thus, there is no performance penalty for using the more
4732readable @code{cl-incf} and @code{push} forms in your compiled code. 4658readable @code{cl-incf} form in your compiled code.
4733 4659
4734@emph{Interpreted} code, on the other hand, must expand these macros 4660@emph{Interpreted} code, on the other hand, must expand these macros
4735every time they are executed. For this reason it is strongly 4661every time they are executed. For this reason it is strongly
4736recommended that code making heavy use of macros be compiled. 4662recommended that code making heavy use of macros be compiled.
4663@c FIXME why are they not labelled as macros?
4737(The features labeled ``Special Form'' instead of ``Function'' in 4664(The features labeled ``Special Form'' instead of ``Function'' in
4738this manual are macros.) A loop using @code{cl-incf} a hundred times 4665this manual are macros.) A loop using @code{cl-incf} a hundred times
4739will execute considerably faster if compiled, and will also 4666will execute considerably faster if compiled, and will also
@@ -4751,7 +4678,7 @@ all Lisp macros which appear in the form. The easiest way to use
4751this function is to go to the @file{*scratch*} buffer and type, say, 4678this function is to go to the @file{*scratch*} buffer and type, say,
4752 4679
4753@example 4680@example
4754(cl-prettyexpand '(loop for x below 10 collect x)) 4681(cl-prettyexpand '(cl-loop for x below 10 collect x))
4755@end example 4682@end example
4756 4683
4757@noindent 4684@noindent
@@ -5104,7 +5031,7 @@ these forms:
5104 5031
5105@example 5032@example
5106(let ((total 0)) (dolist (x my-list) (cl-incf total x)) total) 5033(let ((total 0)) (dolist (x my-list) (cl-incf total x)) total)
5107(loop for x in my-list sum x) 5034(cl-loop for x in my-list sum x)
5108@end example 5035@end example
5109 5036
5110While this would be mainly a stylistic choice in most Common Lisps, 5037While this would be mainly a stylistic choice in most Common Lisps,