From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: tramp-compat-funcall -> compat-funcall? Date: Thu, 22 Sep 2016 08:31:22 -0400 Message-ID: References: <87lgykci0z.fsf@lifelogs.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1474549463 7501 195.159.176.226 (22 Sep 2016 13:04:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 22 Sep 2016 13:04:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 22 15:04:07 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bn3f8-0006RN-M2 for ged-emacs-devel@m.gmane.org; Thu, 22 Sep 2016 15:03:38 +0200 Original-Received: from localhost ([::1]:43885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3f6-0004mT-Vf for ged-emacs-devel@m.gmane.org; Thu, 22 Sep 2016 09:03:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3AI-0007R2-76 for emacs-devel@gnu.org; Thu, 22 Sep 2016 08:31:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn3AE-0003v2-1X for emacs-devel@gnu.org; Thu, 22 Sep 2016 08:31:45 -0400 Original-Received: from [195.159.176.226] (port=41943 helo=blaine.gmane.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3AD-0003tp-Ro for emacs-devel@gnu.org; Thu, 22 Sep 2016 08:31:42 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1bn3A3-0000s3-1h for emacs-devel@gnu.org; Thu, 22 Sep 2016 14:31:31 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 28 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:aX68wEYhK3pbFKe1nUmTTkRFUQY= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207692 Archived-At: > ;; 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 ) ( ...)). 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 possible). 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. Stefan