From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Engster Newsgroups: gmane.emacs.devel Subject: Re: Byte compiler and eval-when-compile Date: Mon, 15 Oct 2012 21:26:37 +0200 Message-ID: <87626b7d02.fsf@engster.org> References: <87a9vn7lhv.fsf@engster.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1350329205 22969 80.91.229.3 (15 Oct 2012 19:26:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 15 Oct 2012 19:26:45 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 15 21:26:52 2012 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 1TNqJQ-0005Rd-Kr for ged-emacs-devel@m.gmane.org; Mon, 15 Oct 2012 21:26:52 +0200 Original-Received: from localhost ([::1]:55786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNqJJ-0002B3-Nm for ged-emacs-devel@m.gmane.org; Mon, 15 Oct 2012 15:26:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNqJH-0002Ax-Q1 for emacs-devel@gnu.org; Mon, 15 Oct 2012 15:26:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TNqJG-0007QP-32 for emacs-devel@gnu.org; Mon, 15 Oct 2012 15:26:43 -0400 Original-Received: from randomsample.de ([83.169.19.17]:47734) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNqJF-0007Pr-Gg for emacs-devel@gnu.org; Mon, 15 Oct 2012 15:26:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=randomsample.de; s=a; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From; bh=nZIe2o4ARXPIn66nAIRAIWEV7Grll0u2MU7a5bzESMA=; b=JuoIXkO/2C2CES561m3jYE9MzrOqBrwmDc4gXzHFTY6hhT6/MFTYbd/ny+0mENaZOIQYA9dIyVjWcBhBLQjNGD+F7bIzpFexaLcShxhD98dN/ghfw5DTApE+/jFQ0Tcm; Original-Received: from dslc-082-083-039-192.pools.arcor-ip.net ([82.83.39.192] helo=spaten) by randomsample.de with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1TNqJC-0006og-Fa; Mon, 15 Oct 2012 21:26:38 +0200 In-Reply-To: (Stefan Monnier's message of "Mon, 15 Oct 2012 14:41:26 -0400") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux) Mail-Followup-To: Stefan Monnier , emacs-devel@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 83.169.19.17 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:154357 Archived-At: Stefan Monnier writes: >> Somehow the byte compiler got smart during the last days (I think it's >> the change in rev. 110510). > > Actually, it just recovered the smartness I added many years ago and > which got broken years ago as well. Just to make sure I understand this right: the byte-compiler will now bark if you're using functions (instead of just macros and defsubsts) from eval-when-compile'd required packages? >> I used to circumvent that problem by simply doing >> (eval-when-compile >> (require 'eldoc)) >> Before you scream at me: I *know* this is not what `eval-when-compile' >> is for, but it has worked until a few days ago. It seems the >> byte-compiler now sees that I'm actually using a function from eldoc, >> but he still doesn't see that I'm requiring the package it in the >> function body. > > If you both do the (eval-when-compile (require 'eldoc)) and the > `require', the byte-compiler could be smarter indeed: when it sees the > inner `require' call, it could check load-history and mark all functions > defined therein as being fine for the current scope. Well, that would be more or less a legalization of the little hack I did so far. >> Do I now really have to use `declare-function' for all those cases? > > Currently, yes (or use an fboundp test, which you probably won't like > any better). Indeed. I will just declare the functions. :-) > I think a good solution to such cases would be to add a `lazy-require': > when interpreted, it works like `require', but the byte-compiler will > turn it into a bunch of autoloads. That would be neat, yes. > A simpler solution might be to provide a new (funcall-require PACKAGE > FUNCTION &rest ARGS), so you'd do > > (funcall-require 'eldoc #'eldoc-function-argstring '("foo" "bar")) > > but the compiler could still be taught to check that > eldoc-function-argstring indeed exists in eldoc and accepts being called > with a single argument. That's pretty much a combination of declare-function and require, isn't it? At least it wouldn't save me any typing. :-) -David