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: Mon, 05 Aug 2013 10:35:22 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1375713370 21901 80.91.229.3 (5 Aug 2013 14:36:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Aug 2013 14:36:10 +0000 (UTC) Cc: Sebastian Wiesner , emacs-devel@gnu.org To: Klaus-Dieter Bauer Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 05 16:36:11 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 1V6LtJ-0002KF-6d for ged-emacs-devel@m.gmane.org; Mon, 05 Aug 2013 16:36:09 +0200 Original-Received: from localhost ([::1]:54237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6LtI-0000Zz-RZ for ged-emacs-devel@m.gmane.org; Mon, 05 Aug 2013 10:36:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6Lsj-00005G-5J for emacs-devel@gnu.org; Mon, 05 Aug 2013 10:35:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6LsZ-0002h4-Sn for emacs-devel@gnu.org; Mon, 05 Aug 2013 10:35:33 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:24320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6LsZ-0002gy-NQ for emacs-devel@gnu.org; Mon, 05 Aug 2013 10:35:23 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFxKix/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOSWpIggV6DEw X-IPAS-Result: Av4EABK/CFFFxKix/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOSWpIggV6DEw X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="20589946" Original-Received: from 69-196-168-177.dsl.teksavvy.com (HELO pastel.home) ([69.196.168.177]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 05 Aug 2013 10:35:16 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 6FE6662D8E; Mon, 5 Aug 2013 10:35:22 -0400 (EDT) In-Reply-To: (Klaus-Dieter Bauer's message of "Mon, 5 Aug 2013 10:52:43 +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:162431 Archived-At: >> As mentioned, the best option is to start by adding warnings for the >> #'symbol form (should be easy: handle it in the same way we handle >> warnings for function calls). >> >> Then make the higher-order functions turn 'symbol into #'symbol. >> That's important for things like >> >> (if foo #'a #'b) > I am not sure I understand what you have in mind. That's because my fingers fumbled. The "That's important for things like" refers to the "warnings for #'" in the previous paragraph. The "Then make the higher..." line should have come afterwards. > (mapcar (if flag 'f1 'f2) list) > => (mapcar (if flag #'f1 #'f2) list) No, I definitely don't want to get into such fanciness. But I do want compiler warnings if the coder writes (mapcar (if flag #'f1 #'f2) list) and `f1' or `f2' are unknown. > (defun select-function (flag f) > (if flag f 'default-f)) > ... > (mapcar (select-function flag 'f1) alist) 100% agreement. > Shouldn't the markup for user-written functions be a bit easier? I'm not too worried about it, no. We should instead aim to teach people to write #'foo instead of 'foo. Given that we can't get warnings for (if a 'foo 'bar), it's OK if you won't get warnings for all cases of (higher-order-func arg1 'foo). > Anyway, I find the behaviour confusing. Having code preloaded into > the binary is okay, but having code in installation directory that is > ignored even when it has been changed seems a bit awkward. Yes, it's a bit confusing. But the source is still very useful (Emacs (and the ideals of Free Software) wants you to have very easy access to the source), so we could arguably get rid of the preloaded .elc files, but we'd still have to keep the .el file, so in most cases you'd still be just as confused. > Or IS it loaded when changed No, it's not re-loaded (we do have such a "re-load" hack in byte-compile-refresh-preloaded but it's only used when rebuilding Emacs to try and minimize the need to bootstrap). > and just didn't change `defun-declaration-alist', because it is bound > already before loading the changed byte-code? Indeed, that's one of the shortcomings of byte-compile-refresh-preloaded. Stefan