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: Changing a cl-defstruct definition in a published package Date: Sun, 15 Jul 2018 21:51:09 -0400 Message-ID: References: <9afc36c6-5759-6ea0-4cd4-9d6eb6b073b5@gmail.com> <87601jx6xa.fsf@gmail.com> <8806cd3a-da5f-28da-1aa6-fff611214396@gmail.com> <33b59faf-9357-706e-2239-68411096bc51@gmail.com> <133dfba4-e6c7-3aca-a39f-4d26a688c8b5@gmail.com> <285c8ce6-3cc0-a4ca-55c2-d95e68f05d22@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1531705767 6417 195.159.176.226 (16 Jul 2018 01:49:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2018 01:49:27 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 16 03:49:23 2018 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 1fesde-0001aR-RW for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2018 03:49:22 +0200 Original-Received: from localhost ([::1]:48475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fesfl-0001PB-Sz for ged-emacs-devel@m.gmane.org; Sun, 15 Jul 2018 21:51:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fesfc-0001Or-Dx for emacs-devel@gnu.org; Sun, 15 Jul 2018 21:51:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fesfZ-00021n-3q for emacs-devel@gnu.org; Sun, 15 Jul 2018 21:51:24 -0400 Original-Received: from [195.159.176.226] (port=40413 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fesfY-0001yy-S9 for emacs-devel@gnu.org; Sun, 15 Jul 2018 21:51:21 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fesdP-0001Hz-E7 for emacs-devel@gnu.org; Mon, 16 Jul 2018 03:49:07 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 42 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:ejCtE4XjZbW/fAwdOZXjJTN/xS4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] 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:227441 Archived-At: >> Note that the recompilation issue can be solved outside of package.el: >> - "recompile package" doesn't have to be in package.el (tho it is its >> most natural place). >> - you could have code in flycheck.el that does: >> >> (eval-when-compile >> (dolist (pkg (find-pkgs-using-the-old-flycheck-object-layout)) >> (recompile-package pkg))) >> >> so it will be executed when flycheck is compiled. > > That's a interesting idea, and a good point. > But wouldn't it have to run *after* Flycheck is compiled? I don't think so, no (by the time we're compiling the file, the package is already installed and activated). You'd need to add some mechanism to avoid infinite-recursion, ideally by somehow checking that we're running this eval-when-compile because of a compilation and not because we're loading the .el file. We could use an ugly hack like (guaranteed 100% untested): (eval-when-compile ;; When handling eval-when-compile, the byte-compiler compiles ;; the form before evaluating it, so in that case the ;; (lambda (x) (+ x 1)) below will be turned into byte-code before ;; we get to the `if` test. In contrast, when we're just loading ;; the .el file, the `lambda` is either left as is or turned into ;; a (closure ...) object (depending on lexical-binding), but in ;; either case it won't be turned into a byte-code. ;; Of course, all of this can be subject to change :-( (when (byte-code-function-p (lambda (x) (+ x 1))) ;; We're in the middle of byte-compiling this file. (dolist (pkg (find-pkgs-using-the-old-flycheck-object-layout)) (recompile-package pkg)))) Better would be to introduce some dedicated feature, like `eval-only-when-compile`. Stefan