From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Last use of defadvice in Emacs Date: Thu, 07 Apr 2022 09:14:47 +0300 Message-ID: <834k35ctd4.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18470"; mail-complaints-to="usenet@ciao.gmane.io" Cc: bug-cc-mode@gnu.org, acm@muc.de, emacs-devel@gnu.org, raman@google.com To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 07 08:19:04 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ncLTz-0004dU-4N for ged-emacs-devel@m.gmane-mx.org; Thu, 07 Apr 2022 08:19:03 +0200 Original-Received: from localhost ([::1]:55864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncLTx-0001iH-GM for ged-emacs-devel@m.gmane-mx.org; Thu, 07 Apr 2022 02:19:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncLPk-0000jr-P8 for emacs-devel@gnu.org; Thu, 07 Apr 2022 02:14:40 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:43592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncLPj-0004Jx-9J; Thu, 07 Apr 2022 02:14:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=yN+xg0nPxRsgTnvUL6y1QeyhQ+sf2j9xdoai4Oyf/QU=; b=QuT7oNcqV+KY RuLhF2g1d1G0RiSV3pQXB3zZL/WGqfY+yW0vojonQbS24a3gtE26DVUQP6+jwILUvkvb58Lv6lsAw lENQmfw0kbZVBE4lU/gkmv/cdIBRtfXe/ZNvYCI1Hqmz5gxEuKTFyuOWzDAmd9Dgzd+4I08wZq2PI Sf1PwD+m5HxKumKx6xbZ6JwVhjptD5J0TFkC7GvGowI0Un5SjTgRCL/8oPDi/fpc+7N8yJHcz1qYN uNHLq4vPVRoEGjvnbyCQQ8Kp8LWV1wbAihjsPN4HX/Hkvq+2X7Xgx/GTOpvRtex1gQccfYGCkV9yG YRVv/6ba/lQ2A+XPQEJHVA==; Original-Received: from [87.69.77.57] (port=1246 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncLPi-0007KY-KP; Thu, 07 Apr 2022 02:14:38 -0400 In-Reply-To: (message from Stefan Monnier on Wed, 06 Apr 2022 22:49:08 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:287874 Archived-At: > From: Stefan Monnier > Cc: Alan Mackenzie , bug-cc-mode@gnu.org, emacs-devel@gnu.org > Date: Wed, 06 Apr 2022 22:49:08 -0400 > > > Could you give some tips on what issues one might see with defadvice > > and its disrespect of lexical bindings? > > IIRC for existing pieces of advice the main issue can occur if an advice > accesses the formal arguments by their name rather than via things like > `ad-get-arg`. IIRC we managed to get it working like it used to in most > cases, but it's not very robust. > > The other issue is that the body of `defadvice` is always evaluated in > the dynamically scoped dialect of ELisp. This means that its local vars > can "leak" to some of the functions they call (as is normal with > dynamic scoping) and that they can't refer to surrounding lexical > variables (more common with `ad-make-advice` than with `defadvice` since > that one is usually used at top-level), ... > > Those problems aren't new. What's "new" is that `advice-add` doesn't > suffer from them. It would be nice if these issues (perhaps in less academic shape and in more practical terms) could be added to the ELisp manual, because AFAICT we currently lack any rationale for people not to use defadvice.