From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Can the byte-compiler check whether functions passed by name are defined? Date: Thu, 01 Aug 2013 16:31:08 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1375389091 19282 80.91.229.3 (1 Aug 2013 20:31:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Aug 2013 20:31:31 +0000 (UTC) Cc: Klaus-Dieter Bauer , emacs-devel@gnu.org To: Sebastian Wiesner Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 01 22:31:32 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V4zX1-000157-Ie for ged-emacs-devel@m.gmane.org; Thu, 01 Aug 2013 22:31:31 +0200 Original-Received: from localhost ([::1]:51968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4zX1-0005CH-6e for ged-emacs-devel@m.gmane.org; Thu, 01 Aug 2013 16:31:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4zWq-0005Bx-0R for emacs-devel@gnu.org; Thu, 01 Aug 2013 16:31:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4zWg-0001KU-0s for emacs-devel@gnu.org; Thu, 01 Aug 2013 16:31:19 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:9608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4zWf-0001KG-Sa for emacs-devel@gnu.org; Thu, 01 Aug 2013 16:31:09 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAFABK/CFG4rw3m/2dsb2JhbABEhke4Rxdzgh4BAQQBIzMjBQsLDgwCGA4CAhQYDSSIHgauX5JOgSOOVIETA5JakiCBXoMT X-IPAS-Result: AgAFABK/CFG4rw3m/2dsb2JhbABEhke4Rxdzgh4BAQQBIzMjBQsLDgwCGA4CAhQYDSSIHgauX5JOgSOOVIETA5JakiCBXoMT X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="20374421" Original-Received: from 184-175-13-230.dsl.teksavvy.com (HELO pastel.home) ([184.175.13.230]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 01 Aug 2013 16:31:02 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 98A4062D79; Thu, 1 Aug 2013 16:31:08 -0400 (EDT) In-Reply-To: (Sebastian Wiesner's message of "Wed, 31 Jul 2013 20:01:17 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:162334 Archived-At: >>> 1. Has to be done, though maybe through a macro, for every higher-order >>> function. >> Note that macroexp.el already has special handling for the main >> higher-order functions (to warn about '(lambda ...)). So it could be >> implemented there. > I presume the list of =E2=80=9Cmain higher-order=E2=80=9D functions is ha= rd-coded > then, isn't it? Currently, yes. It could be moved from macroexp.el's main loop to a bunch of compiler-macros (the code predates the introduction of compiler macros in core Elisp), if needed. > Is there a symbol property or "declare" form to mark specific > arguments as function arguments, to have the same warnings for higher > order functions from 3rd party libraries, too? Similar to how > "docstring" arguments for macros are handled? No, and I think it would be overkill. But 3rd party can also use a compiler-macro to turn the ' into a #'. The approach I use for '(lambda ...) is to emit warnings in the common cases, so that coders will slowly learn, which then benefits all cases. For '(lambda ...) that works well, because removing the ' (or using #') is often useful (making it possible to byte-compile the code, or using lexically bound vars), but for single quoted symbols, the benefit is a lot less clear ("turn 'foo into #'foo to get rid of the silly new warning" only to then get another warning because the compiler doesn't understand that `foo' will very much exist by the time we try to call it). Stefan