[Top][All Lists]

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

Re: tramp-compat-funcall -> compat-funcall?

From: Stefan Monnier
Subject: Re: tramp-compat-funcall -> compat-funcall?
Date: Thu, 22 Sep 2016 08:31:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> ;; For not existing functions, obsolete functions, or functions with a
> ;; changed argument list, there are compiler warnings.  We want to
> ;; avoid them in cases we know what we do.
> (defmacro tramp-compat-funcall (function &rest arguments)
>   "Call FUNCTION if it exists.  Do not raise compiler warnings."
>   `(when (or (subrp ,function) (functionp ,function))
>      (with-no-warnings (funcall ,function ,@arguments))))

[ The `subrp' check looks wrong/redundant.  `functionp' should already return
  non-nil if `function` is a subr (unless it's a special form, in which
  case using `funcall` would be wrong anyway).  ]

FWIW, using tramp-compat-funcall "for not existing functions" is a bad
idea: better use (if (fboundp <foo>) (<foo> ...)).

I think the same kind of consideration should hold for the other two
cases, tho maybe currently the byte-compiler does not offer/detect any
syntax for that.

I think hiding this behind (tramp-)compat-funcall would be better
avoided (just like using with-no-warnings should be avoided whenever

IOW, if there's a kind of situation that recurs often enough to warrant
something like (tramp-)compat-funcall you should report this as a bug.


reply via email to

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