diff options
| author | Stefan Kangas | 2025-02-24 22:21:46 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2025-02-24 22:21:46 +0100 |
| commit | 7d5fe06e79defb0669ef2ba34d644e0836e54a38 (patch) | |
| tree | 914e5619599a08cdc8bca6f552ae69e8825bc38d | |
| parent | c9e681aa0c75feaf1c0a5495b0d475698cbdb653 (diff) | |
| download | emacs-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.texi | 34 | ||||
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/emacs-lisp/cl-macs.el | 1 |
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 | |||
| 2652 | about the types of data that will be stored in particular variables, | 2652 | about the types of data that will be stored in particular variables, |
| 2653 | and about the ways those variables and functions will be used. This | 2653 | and about the ways those variables and functions will be used. This |
| 2654 | package defines versions of all the Common Lisp declaration forms: | 2654 | package 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}. |
| 2656 | and @code{the}. | ||
| 2657 | 2656 | ||
| 2658 | Most of the Common Lisp declarations are not currently useful in Emacs | 2657 | Most of the Common Lisp declarations are not currently useful in Emacs |
| 2659 | Lisp. For example, the byte-code system provides little | 2658 | Lisp. 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} | |||
| 2683 | form.) | 2682 | form.) |
| 2684 | @end defmac | 2683 | @end defmac |
| 2685 | 2684 | ||
| 2686 | @defmac cl-declare decl-specs@dots{} | ||
| 2687 | This macro is used to make declarations within functions and other | ||
| 2688 | code. Common Lisp allows declarations in various locations, generally | ||
| 2689 | at the beginning of any of the many ``implicit @code{progn}s'' | ||
| 2690 | throughout Lisp syntax, such as function bodies, @code{let} bodies, | ||
| 2691 | etc. Currently the only declaration understood by @code{cl-declare} | ||
| 2692 | is @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 |
| 2697 | optimization settings permit) that it is of type @code{type}. Future | 2687 | optimization 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 | |||
| 2707 | to @code{(mapcar 'car foo)}. | 2697 | to @code{(mapcar 'car foo)}. |
| 2708 | @end defmac | 2698 | @end defmac |
| 2709 | 2699 | ||
| 2710 | Each @var{decl-spec} in a @code{cl-proclaim}, @code{cl-declaim}, or | 2700 | Each @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 | 2701 | should be a list beginning with a symbol that says |
| 2712 | what kind of declaration it is. This package currently understands | 2702 | what 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}, |
| 2714 | and @code{warn} declarations. (The @code{warn} declaration is an | 2704 | and @code{warn} declarations. (The @code{warn} declaration is an |
| @@ -2726,9 +2716,6 @@ bound in the body of the function. The compiler normally emits | |||
| 2726 | warnings for such references, since they could be typographical | 2716 | warnings for such references, since they could be typographical |
| 2727 | errors for references to local variables. | 2717 | errors for references to local variables. |
| 2728 | 2718 | ||
| 2729 | The declaration @code{(cl-declare (special @var{var1} @var{var2}))} is | ||
| 2730 | equivalent to @code{(defvar @var{var1}) (defvar @var{var2})}. | ||
| 2731 | |||
| 2732 | In top-level contexts, it is generally better to write | 2719 | In 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}))}, |
| 2734 | since @code{defvar} makes your intentions clearer. | 2721 | since @code{defvar} makes your intentions clearer. |
| @@ -2760,12 +2747,6 @@ request that a function you have defined should be inlined, | |||
| 2760 | but it is impolite to use it to request inlining of an external | 2747 | but it is impolite to use it to request inlining of an external |
| 2761 | function. | 2748 | function. |
| 2762 | 2749 | ||
| 2763 | In Common Lisp, it is possible to use @code{(declare (inline @dots{}))} | ||
| 2764 | before a particular call to a function to cause just that call to | ||
| 2765 | be inlined; the current byte compilers provide no way to implement | ||
| 2766 | this, so @code{(cl-declare (inline @dots{}))} is currently ignored by | ||
| 2767 | this package. | ||
| 2768 | |||
| 2769 | @item notinline | 2750 | @item notinline |
| 2770 | The @code{notinline} declaration lists functions which should | 2751 | The @code{notinline} declaration lists functions which should |
| 2771 | not be inlined after all; it cancels a previous @code{inline} | 2752 | not be inlined after all; it cancels a previous @code{inline} |
| @@ -2800,12 +2781,7 @@ Emacs itself, Emacs will not crash with a segmentation fault | |||
| 2800 | just because of an error in a fully-optimized Lisp program. | 2781 | just because of an error in a fully-optimized Lisp program. |
| 2801 | 2782 | ||
| 2802 | The @code{optimize} declaration is normally used in a top-level | 2783 | The @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. |
| 2804 | it to be used with @code{declare} to set the level of optimization | ||
| 2805 | locally for a given form, but this will not work correctly with the | ||
| 2806 | current byte-compiler. (The @code{cl-declare} | ||
| 2807 | will set the new optimization level, but that level will not | ||
| 2808 | automatically be unset after the enclosing form is done.) | ||
| 2809 | 2785 | ||
| 2810 | @item warn | 2786 | @item warn |
| 2811 | This declaration controls what sorts of warnings are generated | 2787 | This declaration controls what sorts of warnings are generated |
| @@ -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. |
| 538 | It is an alias for the 'progn' special-form. | 538 | It 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 | ||
| 2729 | will turn off byte-compile warnings in the function. | 2729 | will turn off byte-compile warnings in the function. |
| 2730 | See Info node `(cl)Declarations' for details." | 2730 | See 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)) |