Subject: bug#63288: [PATCH] Mark cl-proclaim, cl-declaim, and cl-declare as obsolete

From: Thierry Volpiatto <[email-masked]>
Date: Thu, 20 Feb 2025 04:28:47 +0000

Thierry Volpiatto <[email-masked]> writes:

> Stefan Monnier <[email-masked]> writes:
>
>>>>> No, in some cases you must use (cl-declare (special ...)), and no you
>>>>> can't use defvar in such cases, so if you intend to remove/deprecate
>>>> Could you show us an example?
>>> I used it in helm--completion-in-region to pass PROMPT and
>>> REQUIRE-MATCH,
>>
>> Actually, no, you didn't.  🙁
>> I mean, yes you did use it, but no it did not "pass PROMPT and
>> REQUIRE-MATCH".
>
> It used to work (circa 26?), but yes now it is broken, since when I
> don't know, I rarely use CRM (I saw just yesterday PROMPT was no more
> passing, thanks to this thread).  So because this is no more working, I
> understand you don't want to bother maintaining this code which looks
> complex indeed.
>
>
>>> (defmacro my-with-progress (&rest body)
>>>   `(let ((reporter (make-progress-reporter "Updating...")))
>>>      (progn
>>>        ,@body)))
>>>
>>> (defun my-updating ()
>>>   (cl-declare (special reporter))
>>>   (my-with-progress
>>>    (cl-loop for elm in '(a b c d e f g)
>>>             do (progn
>>>                  (sit-for 1)
>>>                  (progress-reporter-update reporter))
>>>             collect elm)))
>>
>> I don't see what is the use of (cl-declare (special reporter)) here.
>> What do you think it changes to the behavior of this code?
>
> It declare reporter as a variable and prevent byte compile warnings,
> same as (defvar reporter) as you have mentioned below.

In fact such code is reporting warnings when using (defvar reporter)
instead of cl-declare:

helm-all-the-icons.el:32:9: Warning: global/dynamic var ‘reporter’ lacks a prefix
helm-all-the-icons.el:42:75: Warning: Lexical argument shadows the dynamic variable reporter

So for this to work I would have to give a prefix to reporter and a nil
value and initialize it with setq, then disable the reporter and
reinitialize the var to nil when done (optional), less handy that cl-declare.

>>> of course you can use a defvar in this case,
>>
>> Exactly: (defvar reporter) would have the same effect.
>>
>>
>>         Stefan

-- 
Thierry