emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Improve detection of local function calls in methods


From: Stefan Monnier
Subject: Re: [PATCH] Improve detection of local function calls in methods
Date: Fri, 27 Aug 2021 18:59:11 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Instead of using unreliale and expensive macroexp--fgrep, we record the
> relevant calls in the macroexpansion, as suggested in the FIXME entry.

Yes, please!

> +  (defvar cl-generic--uses-cnm nil
> +    ;; It would be better to declare the variable special
> +    ;; locally where it's used
> +    ;; but there is no support for local special declarations in Elisp.

[ I'm not completely sure what you mean, but (defvar foo) has an effect
  limited to the current scope.  This said, I don't think it matters
  much here, because using a globally declared dynvar is perfectly fine
  IMO (the main reason not to use a globally declared dynvar is either
  because we really want to keep the global definition unbound or
  because we really don't want to give the var a namespace prefix).  ]

> -                        `(cl-flet ((cl-call-next-method ,cnm)
> -                                   (cl-next-method-p ,nmp))
> +                        `(cl-macrolet ((cl-call-next-method
> +                                        (&rest args)
> +                                        (prog1 `(funcall ,',cnm ,@args)
> +                                          (cl-pushnew
> +                                           ',cnm cl-generic--uses-cnm
> +                                           :test #'eq)))
> +                                       (cl-next-method-p
> +                                        ()
> +                                        (prog1 `(funcall ,',nmp)
> +                                          (cl-pushnew
> +                                           ',nmp cl-generic--uses-cnm
> +                                           :test #'eq))))

Hmm... IIUC this fails to account for the case where
#'cl-call-next-method is passed to a function (the most common case (or
more precisely, the only case I've seen so far) being when it's passed
to `apply`).


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]