aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2025-02-24 22:21:46 +0100
committerStefan Kangas2025-02-24 22:21:46 +0100
commit7d5fe06e79defb0669ef2ba34d644e0836e54a38 (patch)
tree914e5619599a08cdc8bca6f552ae69e8825bc38d
parentc9e681aa0c75feaf1c0a5495b0d475698cbdb653 (diff)
downloademacs-7d5fe06e79defb0669ef2ba34d644e0836e54a38.tar.gz
emacs-7d5fe06e79defb0669ef2ba34d644e0836e54a38.zip
Make cl-declare obsolete
* lisp/emacs-lisp/cl-macs.el (cl-declare): Make obsolete. * doc/misc/cl.texi (Declarations): Don't document above obsolete macro. (Bug#63288)
-rw-r--r--doc/misc/cl.texi34
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/emacs-lisp/cl-macs.el1
3 files changed, 9 insertions, 29 deletions
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 8fb308e64a5..862b8f4a1c4 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -60,7 +60,7 @@ modify this GNU manual.''
60* Predicates:: Type predicates and equality predicates. 60* Predicates:: Type predicates and equality predicates.
61* Control Structure:: Assignment, conditionals, blocks, looping. 61* Control Structure:: Assignment, conditionals, blocks, looping.
62* Macros:: Destructuring, compiler macros. 62* Macros:: Destructuring, compiler macros.
63* Declarations:: @code{cl-proclaim}, @code{cl-declare}, etc. 63* Declarations:: @code{cl-proclaim}, @code{cl-declaim}, etc.
64* Symbols:: Property lists, creating symbols. 64* Symbols:: Property lists, creating symbols.
65* Numbers:: Predicates, functions, random numbers. 65* Numbers:: Predicates, functions, random numbers.
66* Sequences:: Mapping, functions, searching, sorting. 66* Sequences:: Mapping, functions, searching, sorting.
@@ -2652,8 +2652,7 @@ mechanism that allows you to give the compiler special hints
2652about the types of data that will be stored in particular variables, 2652about the types of data that will be stored in particular variables,
2653and about the ways those variables and functions will be used. This 2653and about the ways those variables and functions will be used. This
2654package defines versions of all the Common Lisp declaration forms: 2654package defines versions of all the Common Lisp declaration forms:
2655@code{declare}, @code{locally}, @code{proclaim}, @code{declaim}, 2655@code{proclaim}, @code{declaim}, and @code{the}.
2656and @code{the}.
2657 2656
2658Most of the Common Lisp declarations are not currently useful in Emacs 2657Most of the Common Lisp declarations are not currently useful in Emacs
2659Lisp. For example, the byte-code system provides little 2658Lisp. For example, the byte-code system provides little
@@ -2683,15 +2682,6 @@ compiler treats the rest of the file that contains the @code{cl-declaim}
2683form.) 2682form.)
2684@end defmac 2683@end defmac
2685 2684
2686@defmac cl-declare decl-specs@dots{}
2687This macro is used to make declarations within functions and other
2688code. Common Lisp allows declarations in various locations, generally
2689at the beginning of any of the many ``implicit @code{progn}s''
2690throughout Lisp syntax, such as function bodies, @code{let} bodies,
2691etc. Currently the only declaration understood by @code{cl-declare}
2692is @code{special}.
2693@end defmac
2694
2695@defmac cl-the type form 2685@defmac cl-the type form
2696@code{cl-the} returns the value of @code{form}, first checking (if 2686@code{cl-the} returns the value of @code{form}, first checking (if
2697optimization settings permit) that it is of type @code{type}. Future 2687optimization settings permit) that it is of type @code{type}. Future
@@ -2707,8 +2697,8 @@ For now, Emacs Lisp will treat the above code as exactly equivalent
2707to @code{(mapcar 'car foo)}. 2697to @code{(mapcar 'car foo)}.
2708@end defmac 2698@end defmac
2709 2699
2710Each @var{decl-spec} in a @code{cl-proclaim}, @code{cl-declaim}, or 2700Each @var{decl-spec} in a @code{cl-proclaim} or @code{cl-declaim}
2711@code{cl-declare} should be a list beginning with a symbol that says 2701should be a list beginning with a symbol that says
2712what kind of declaration it is. This package currently understands 2702what kind of declaration it is. This package currently understands
2713@code{special}, @code{inline}, @code{notinline}, @code{optimize}, 2703@code{special}, @code{inline}, @code{notinline}, @code{optimize},
2714and @code{warn} declarations. (The @code{warn} declaration is an 2704and @code{warn} declarations. (The @code{warn} declaration is an
@@ -2726,9 +2716,6 @@ bound in the body of the function. The compiler normally emits
2726warnings for such references, since they could be typographical 2716warnings for such references, since they could be typographical
2727errors for references to local variables. 2717errors for references to local variables.
2728 2718
2729The declaration @code{(cl-declare (special @var{var1} @var{var2}))} is
2730equivalent to @code{(defvar @var{var1}) (defvar @var{var2})}.
2731
2732In top-level contexts, it is generally better to write 2719In top-level contexts, it is generally better to write
2733@code{(defvar @var{var})} than @code{(cl-declaim (special @var{var}))}, 2720@code{(defvar @var{var})} than @code{(cl-declaim (special @var{var}))},
2734since @code{defvar} makes your intentions clearer. 2721since @code{defvar} makes your intentions clearer.
@@ -2760,12 +2747,6 @@ request that a function you have defined should be inlined,
2760but it is impolite to use it to request inlining of an external 2747but it is impolite to use it to request inlining of an external
2761function. 2748function.
2762 2749
2763In Common Lisp, it is possible to use @code{(declare (inline @dots{}))}
2764before a particular call to a function to cause just that call to
2765be inlined; the current byte compilers provide no way to implement
2766this, so @code{(cl-declare (inline @dots{}))} is currently ignored by
2767this package.
2768
2769@item notinline 2750@item notinline
2770The @code{notinline} declaration lists functions which should 2751The @code{notinline} declaration lists functions which should
2771not be inlined after all; it cancels a previous @code{inline} 2752not be inlined after all; it cancels a previous @code{inline}
@@ -2800,12 +2781,7 @@ Emacs itself, Emacs will not crash with a segmentation fault
2800just because of an error in a fully-optimized Lisp program. 2781just because of an error in a fully-optimized Lisp program.
2801 2782
2802The @code{optimize} declaration is normally used in a top-level 2783The @code{optimize} declaration is normally used in a top-level
2803@code{cl-proclaim} or @code{cl-declaim} in a file; Common Lisp allows 2784@code{cl-proclaim} or @code{cl-declaim} in a file.
2804it to be used with @code{declare} to set the level of optimization
2805locally for a given form, but this will not work correctly with the
2806current byte-compiler. (The @code{cl-declare}
2807will set the new optimization level, but that level will not
2808automatically be unset after the enclosing form is done.)
2809 2785
2810@item warn 2786@item warn
2811This declaration controls what sorts of warnings are generated 2787This declaration controls what sorts of warnings are generated
diff --git a/etc/NEWS b/etc/NEWS
index 4c0cff8ac7c..763ff2206ac 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -537,6 +537,9 @@ Such bindings make it possible to compute which function to bind to FUNC.
537*** 'cl-locally' is now obsolete. 537*** 'cl-locally' is now obsolete.
538It is an alias for the 'progn' special-form. 538It is an alias for the 'progn' special-form.
539 539
540+++
541*** 'cl-declare' is now obsolete; use 'defvar' instead.
542
540** Whitespace 543** Whitespace
541 544
542--- 545---
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 1578603cedd..dbaa0d9bcb8 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2728,6 +2728,7 @@ For instance
2728 2728
2729will turn off byte-compile warnings in the function. 2729will turn off byte-compile warnings in the function.
2730See Info node `(cl)Declarations' for details." 2730See Info node `(cl)Declarations' for details."
2731 (declare (obsolete defvar "31.1"))
2731 (if (macroexp-compiling-p) 2732 (if (macroexp-compiling-p)
2732 (while specs 2733 (while specs
2733 (if (listp cl--declare-stack) (push (car specs) cl--declare-stack)) 2734 (if (listp cl--declare-stack) (push (car specs) cl--declare-stack))