From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: A combination of defmacro, functionp, and quoted lambdas yields different results on consecutive evaluations Date: Wed, 28 Feb 2018 09:32:27 -0500 Message-ID: <7cf85a31-89c6-dd6e-f902-9279baae2b37@gmail.com> References: <08190786-14de-a899-f591-a7043c87bebb@gmail.com> <9dbc26f4-e86f-c3df-8193-61a0a3837466@gmail.com> <10414fb8-e09c-a4fa-dcd1-5ccfff10650d@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1519828385 21536 195.159.176.226 (28 Feb 2018 14:33:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 28 Feb 2018 14:33:05 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 28 15:33:01 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 1er2my-00054V-KE for ged-emacs-devel@m.gmane.org; Wed, 28 Feb 2018 15:33:00 +0100 Original-Received: from localhost ([::1]:44662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er2p0-0003c0-Vc for ged-emacs-devel@m.gmane.org; Wed, 28 Feb 2018 09:35:06 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er2mZ-0002Ta-Of for emacs-devel@gnu.org; Wed, 28 Feb 2018 09:32:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er2mT-0004r9-O8 for emacs-devel@gnu.org; Wed, 28 Feb 2018 09:32:35 -0500 Original-Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:33865) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1er2mT-0004r1-Is for emacs-devel@gnu.org; Wed, 28 Feb 2018 09:32:29 -0500 Original-Received: by mail-qk0-x232.google.com with SMTP id l206so3207234qke.1 for ; Wed, 28 Feb 2018 06:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4g7GqjSWdDSPXQiaz6rVwSXfRBB19snZQsuIaXr/nF8=; b=GUh4ZHl9GLB7S/WKHY8S97U88BefMpLSXQjIWAP4eNHcqwwgIbGbV2Yd9rqDPmUmVj 38kQ736tgWGTvL6CFsklRUaygQEm/5PePYi2dT54xd388bL0iwUcIivu9T7bfzWxmvfX ke0R3svDobDfikv0ctcX+vYdXssaG1CF8+woPJHVALpD/0qRBLMvgUredEywvzQp2mzO nrmY1xjUmEB/8N4cAoPeH7tfnbIWdt0QsTgapNGjOfOWnLMfoOJkR6OxHV7quRPrsJka nurp6657tWfLNmcizLUqtSf6dVqMiiMJeHXMdjkeekRU/wBA+MFPL9csKVv4bbFIm7HG ievg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4g7GqjSWdDSPXQiaz6rVwSXfRBB19snZQsuIaXr/nF8=; b=eCyua07+1/Qu/Q0vCjMTl0vjLlT+tfOf6xW8gJkkM1OeE3Eqap0YVP4eYAvDt9u0wj 0m/lmq6vhSz+NbXzfXM61wPfyaKWxImy6TD+TDbFLs+CgCr5ndf+2gGEQ8kJUeBDqCvA gdrP5TL7oG60B6LHRbKHxssE3A3NgCUZ9b232YiA75NCYTe3dxNOSjz6yKWtsPGnEgwC Fa6Wlsn5gW/pe8CglEU2t1Sg1gR79C7RXohP/8C5FTg5hNyQ5ajRz/kJVgQZtpA3H/HA gw52fmg/n3YwyBKvhXGQyA1ltRT8FdSgq063Wl6Yy7R47dyFI1IpVziDy9iqGYquBkqN 8lRQ== X-Gm-Message-State: APf1xPBY9QJOn0qFoce9CWICYDsfkg7/tNG1DRQBcET6PvUYoMkCac25 MxvBt+1bU6OjAe/GBbjic35Chn8+ X-Google-Smtp-Source: AG47ELtqH19SkFRfzSFxVW/1an6k8Yx6M/etagiSXBEKbNznLQBkTZ5J2tWcVjvNJPdJqjcr79LscQ== X-Received: by 10.55.124.67 with SMTP id x64mr12126012qkc.137.1519828348875; Wed, 28 Feb 2018 06:32:28 -0800 (PST) Original-Received: from ?IPv6:2601:184:4180:66e7:3caa:840d:c217:daa5? ([2601:184:4180:66e7:3caa:840d:c217:daa5]) by smtp.gmail.com with ESMTPSA id x28sm1309913qtx.20.2018.02.28.06.32.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 06:32:28 -0800 (PST) In-Reply-To: Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::232 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:223166 Archived-At: On 2018-02-26 12:31, Stefan Monnier wrote: >> Is that actually a usable criterion? Any macro can quote or unquote its >> argument, right? > > Everything can happen, indeed. But usually a macro which takes a code > argument and puts it within a quote is perceived as a problem: e.g. it > tends to very quickly annoy its users because they can't refer to > lexically-scoped arguments any more. Admittedly, for > with-eval-after-load this is not very problematic because it's unusual > to have with-eval-after-load elsewhere than at top-level, so making code > like: > > (let ((x 1)) > (with-eval-after-load FOO > (message "%S" x))) > > work correctly is not nearly as important as it is for many other macros. Thanks, this is a good point, which I hadn't considered. It's not obvious to me, however, which one is more important: make something like (with-eval-after-load 'flycheck (flycheck-define-checker …)) work, or ensuring that with-eval-after-load can be used to capture lexical variables. One of the issues to consider is that the usual fix of (require)-ing — or (require-when-compile)-ing — the package that defines the macro isn't satisfactory in this case, since with-eval-after-load is used to run code *after* the package is loaded. And, since eval-when-compile now behaves the same way, there doesn't seem to be a user-friendly way at the moment to delay the execution a bit of code that includes macros until these macros are available. Btw, autoloading these macros wouldn't fix this, right? >> For example, the problem that I described about with-eval-after-load >> also happens with eval-after-load, yet the argument to that is quoted. > > [ I was wondering when someone would notice. ] > > Indeed, when I introduced `with-eval-after-load` and I also changed > `eval-after-load` by adding a compiler macro which turns > > (eval-after-load FOO 'BAR) > into > (eval-after-load FOO `(,(lambda () BAR))) > > so that BAR can be properly eagerly macro-expanded, so the > byte-compiler can look at BAR and emit warnings about it, That makes sense, but it also has high rates of false positives; writing the following warns on foo-x: (eval-after-load 'foo '(setq foo-x 1)) … regardless f whether `foo' defines `foo-x'. > Here's the kind of thing I had in mind (can't think of any concrete > example for it, tho, the motivation came from such cases in defadvice > and interactive forms instead, which had the same problem is keeping > code quoted thus preventing compilation and eager macroexpansion): > > (eval-when-compile (require 'cl)) > (eval-after-load FOO '(flet ...)) I see. Tricky. > There are a few other places where we "undo" a quote, as in > > (mapcar '(lambda ...) ...) > > These were all done because it seemed to be beneficial more often than > it is harmful. I must admit that I wasn't 100% sure that "unquoting" > its arg was "more often beneficial", tho the fact that I haven't heard > anyone even mention this until now seems to argue that even tho it's > maybe not "more often beneficial" at least not often harmful. I think we've had that particular issue for a while in Flycheck — it's just that we didn't understand it until fairly recently. It pops up when people put stuff in their use-package configuration, in particular. Clément.