From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Paul Pogonyshev Newsgroups: gmane.emacs.devel Subject: Re: byte-code optimizations Date: Wed, 22 Sep 2004 01:25:03 -0200 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: <200409220125.03345.pogonyshev@gmx.net> References: <200409181152.15364.pogonyshev@gmx.net> <200409212242.47848.pogonyshev@gmx.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1095805838 18505 80.91.229.6 (21 Sep 2004 22:30:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 21 Sep 2004 22:30:38 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 22 00:30:29 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1C9t9Z-0003sH-00 for ; Wed, 22 Sep 2004 00:30:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C9tFW-0007t5-4U for ged-emacs-devel@m.gmane.org; Tue, 21 Sep 2004 18:36:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C9tFP-0007sm-L8 for emacs-devel@gnu.org; Tue, 21 Sep 2004 18:36:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C9tFO-0007sH-5a for emacs-devel@gnu.org; Tue, 21 Sep 2004 18:36:31 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C9tFO-0007sE-2v for emacs-devel@gnu.org; Tue, 21 Sep 2004 18:36:30 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.34) id 1C9t9F-000051-Ne for emacs-devel@gnu.org; Tue, 21 Sep 2004 18:30:10 -0400 Original-Received: (qmail 10383 invoked by uid 65534); 21 Sep 2004 22:23:26 -0000 Original-Received: from unknown (EHLO localhost.localdomain) (195.50.12.120) by mail.gmx.net (mp001) with SMTP; 22 Sep 2004 00:23:26 +0200 X-Authenticated: #16844820 Original-To: Stefan Monnier User-Agent: KMail/1.4.3 In-Reply-To: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 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 Xref: main.gmane.org gmane.emacs.devel:27400 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:27400 Stefan wrote: > >> However, there is still the question of whether we should > >> change the standard defsubst to work the way defsubst* does. > > > > Maybe we can even use `defmacro' for `caar' and friends. Since > > they evaluate their lone argument only once, there must not be > > any problems, right? > > Just think of (mapcar 'caar x) Point. > > If this (or `defsubst*') works, I'll investigate whether this > > byte-code optimization gives any improvement after such a change. > > What defsubst* does is treat the argument as a kind of "lexically scope= d" > variable, but only in very limited ways. I.e. the > > (defsubst* caar (x) (car (car x))) > > will expand: > > (caar y) =3D> (car (car y)) > (caar (f y)) =3D> (let ((x (f y))) ..cl-gunk.. (car (car x))) > > [ The cl-gunk is stuff added by CL for CL such as a `catch' statement. = ] > If you ignore the nasty cl-gunk, I think the resulting optimization is > similar to what we get, except it works in a few more cases. > E.g. it'll expand > > (defsubst* foo (x) (symbol-value x)) > > (foo y) =3D> (symbol-value y) > > whereas our optimization won't be able to do that because it can't assu= me > a "somewhat lexically scoped" semantics. Then byte-code optimization probably has only one advantage: it works for normal `let' bindings too. Probably not a particularly strong advantage, though, as there must not be many so simple `let's around. Will replacing `defsubst' definition with `defsubst*' or something similar be visible from ``outside?'' Or, on a smaller scale, will redefining `caar' and friends with `defsubst*' be? Paul