From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Markus Triska Newsgroups: gmane.emacs.devel Subject: Re: Nonsensical byte compiler warning. Date: Sun, 08 Apr 2007 22:47:34 +0200 Message-ID: <87tzvqpp95.fsf@gmx.at> References: <85ps6okoe5.fsf@lola.goethe.zz> <87lkhcj791.fsf@stupidchicken.com> <87tzvwvj6c.fsf@gmx.at> <861wj04qcq.fsf@lola.quinscape.zz> <873b3gpn4u.fsf@gmx.at> <86fy7g34tk.fsf@lola.quinscape.zz> <87r6qzqmpg.fsf@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1176065302 23660 80.91.229.12 (8 Apr 2007 20:48:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 8 Apr 2007 20:48:22 +0000 (UTC) Cc: acm@muc.de, cyd@stupidchicken.com, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 08 22:47:53 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HaeIh-0002hk-8G for ged-emacs-devel@m.gmane.org; Sun, 08 Apr 2007 22:47:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HaeMR-0000Uc-5r for ged-emacs-devel@m.gmane.org; Sun, 08 Apr 2007 16:51:43 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HaeMM-0000Ng-99 for emacs-devel@gnu.org; Sun, 08 Apr 2007 16:51:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HaeMK-0000Gy-4j for emacs-devel@gnu.org; Sun, 08 Apr 2007 16:51:37 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HaeMJ-0000Gu-Ui for emacs-devel@gnu.org; Sun, 08 Apr 2007 16:51:35 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1HaeIZ-00071u-05 for emacs-devel@gnu.org; Sun, 08 Apr 2007 16:47:43 -0400 Original-Received: (qmail invoked by alias); 08 Apr 2007 20:47:41 -0000 Original-Received: from chello062178240212.3.14.tuwien.teleweb.at (EHLO enterprise) [62.178.240.212] by mail.gmx.net (mp016) with SMTP; 08 Apr 2007 22:47:41 +0200 X-Authenticated: #4064391 X-Provags-ID: V01U2FsdGVkX18EQXVPcD8EyewjyoZr5AAaHPXEJIDPNdncmXS3c+ n8j1htBaiLGqpM In-Reply-To: (Richard Stallman's message of "Fri\, 06 Apr 2007 08\:56\:59 -0400") X-Y-GMX-Trusted: 0 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) 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: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:69197 Archived-At: Richard Stallman writes: > I agree this is too hard to change now. > However, it would have been premature to give up without > checking. Sure; here's a rather trivial compromise for `char-before': It makes the compiler rewrite calls to char-before at the time the byte-code is emitted instead of during the optimisation phase. This retains the correct function call in the warning. It can yield slightly inferior byte-code though (with usage-patterns that don't occur in Emacs trunk and are probably rather atypical). If you find this change advisable, I'll implement analogous changes for backward-char and backward-word. 2007-04-08 Markus Triska * emacs-lisp/byte-opt.el: remove char-before rewriting * emacs-lisp/bytecomp.el: add char-before rewriting *** byte-opt.el 04 Apr 2007 19:36:54 +0200 1.88 --- byte-opt.el 08 Apr 2007 21:33:44 +0200 *************** *** 1158,1171 **** '(forward-word -1)) (t form))) - (put 'char-before 'byte-optimizer 'byte-optimize-char-before) - (defun byte-optimize-char-before (form) - (cond ((= 2 (safe-length form)) - `(char-after (1- ,(nth 1 form)))) - ((= 1 (safe-length form)) - '(char-after (1- (point)))) - (t form))) - ;; Fixme: delete-char -> delete-region (byte-coded) ;; optimize string-as-unibyte, string-as-multibyte, string-make-unibyte, ;; string-make-multibyte for constant args. --- 1158,1163 ---- *** bytecomp.el 27 Mar 2007 08:08:58 +0200 2.196 --- bytecomp.el 08 Apr 2007 21:52:58 +0200 *************** *** 3148,3153 **** --- 3148,3154 ---- ;; more complicated compiler macros + (byte-defop-compiler char-before) (byte-defop-compiler list) (byte-defop-compiler concat) (byte-defop-compiler fset) *************** *** 3159,3164 **** --- 3160,3172 ---- (byte-defop-compiler19 (/ byte-quo) byte-compile-quo) (byte-defop-compiler19 nconc) + (defun byte-compile-char-before (form) + (cond ((= 2 (length form)) + (byte-compile-form `(char-after (1- ,(nth 1 form))))) + ((= 1 (length form)) + (byte-compile-form '(char-after (1- (point))))) + (t (byte-compile-subr-wrong-args form "0-1")))) + (defun byte-compile-list (form) (let ((count (length (cdr form)))) (cond ((= count 0)