From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: Predicate for true lists Date: Tue, 09 Apr 2019 17:20:00 +0100 Message-ID: <87mukzb173.fsf@tcd.ie> References: <87fu3vdjjk.fsf@tcd.ie> <87bmcqhhsf.fsf@tcd.ie> <87in6xgtpb.fsf@tcd.ie> <2af892df-26cb-60b2-4fd8-067fcb3d32e9@cs.ucla.edu> <87r2kh9uwx.fsf@tcd.ie> <83h8lcnbxb.fsf@gnu.org> <87sh4s9poo.fsf@tcd.ie> <87k1q49p0i.fsf@tcd.ie> <87efgbbq2p.fsf@tcd.ie> <87a7gz8hp2.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="173945"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 09 18:25:32 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDtYx-000j2C-4U for ged-emacs-devel@m.gmane.org; Tue, 09 Apr 2019 18:25:31 +0200 Original-Received: from localhost ([127.0.0.1]:45865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hDtYw-0006XE-1K for ged-emacs-devel@m.gmane.org; Tue, 09 Apr 2019 12:25:30 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hDtTl-0001wC-RB for emacs-devel@gnu.org; Tue, 09 Apr 2019 12:20:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hDtTi-0001jM-M8 for emacs-devel@gnu.org; Tue, 09 Apr 2019 12:20:09 -0400 Original-Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]:39988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hDtTh-0001f3-NC for emacs-devel@gnu.org; Tue, 09 Apr 2019 12:20:06 -0400 Original-Received: by mail-ed1-x542.google.com with SMTP id h22so15499638edw.7 for ; Tue, 09 Apr 2019 09:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=yTyqf3no7JbxJvtjiWyQ3eor1uzn2iay1nW5x+xGC3A=; b=tZQjD+VGoEMxxHyThHliByPybLyl3qcznHsYxeb1wLVb0uvGDI6/he+ZkpYWmJ+ez+ SY9Ebj0VRPfe9xXbMR6PbUPaB1n+7JXRcr7MulLUsCx4/vamLYy4m8/q69WA5GZ/tw1s B6vHShPGhi8N3xnzkc0GvPX41Bo2IMra35EJ5k/Xa0pIvmiWk7EEshdkltdRch54GW9H shtwx9AK+9D9hUCVBDwO+XqrM2gRSYN13L6E8WM4dgAr2bxW0AMwUU8+/UjTlFtqY+sK +klEp6AY4n0CbP8Rsep7JFXuL6qJN6jqHna7YO6kQgYd3oc/lb2gKB/oksATSRtv6wl8 leJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=yTyqf3no7JbxJvtjiWyQ3eor1uzn2iay1nW5x+xGC3A=; b=qhlgKSOLdbkV1IdslUIL2xtY95mIJ3fPUfS2EPySKJAS7cehDJ44PizuNt8RDn4s/G IQ4EBfvT8hjeHHW7j/PNZwCLsZdO7lnos1/NCX84PROjMTYhztRhqJqdHpo0gr//6E7k tBEqBKau4zXCe6BaBeJj/HxwBYi0pxSproAukzOtBvaw7T0r+F354sEf23iGFWqLzb/r T6LP3KqJRRXSikUoDVk+H+zfsm83nD80bd7hYonP4MWk1LImx8hhOUACcpKcc+o75TZK 288uK5WFM7VvGuG/W5045/k3bxDPPxL8fYQGK81hK4r0gp7vkR2VEwQZH3qzoW1BD9AS P4Sw== X-Gm-Message-State: APjAAAXz742LqO7vEDLKOSrX5ye/3hY6JMXCGbZu/1vnWnsJ0+ePYQzf oZjMZa9la90HjCyz4p+1m6EYTwos2gS9GDeS X-Google-Smtp-Source: APXvYqwZtSwPuNWqqu3WZpAPWywa6HJAn7WDH5GZhs6aTYCCs1x4xiN0gAQG2KZdpZ+TgsaAEJql7A== X-Received: by 2002:a17:906:f84:: with SMTP id q4mr20599642ejj.117.1554826803396; Tue, 09 Apr 2019 09:20:03 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:f786:805d:f4ab:1006]) by smtp.gmail.com with ESMTPSA id c57sm9954964ede.28.2019.04.09.09.20.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Apr 2019 09:20:01 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Tue, 9 Apr 2019 11:33:59 -0400") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::542 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:235169 Archived-At: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Optimize-byte-compilation-of-proper-list-p.patch >From 430fcb473608a4501826a982a29efa8c31ed6c5c Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Tue, 9 Apr 2019 16:51:55 +0100 Subject: [PATCH 1/2] Optimize byte-compilation of proper-list-p * lisp/emacs-lisp/byte-opt.el: Optimize proper-list-p as a predicate. * src/fns.c (syms_of_fns): Mark proper-list-p as pure and side-effect-free. --- lisp/emacs-lisp/byte-opt.el | 3 ++- src/fns.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 33d4964763..44cca6136c 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -879,7 +879,8 @@ byte-optimize-memq (put 'symbolp 'byte-optimizer 'byte-optimize-predicate) (put 'stringp 'byte-optimizer 'byte-optimize-predicate) (put 'string< 'byte-optimizer 'byte-optimize-predicate) -(put 'string-lessp 'byte-optimizer 'byte-optimize-predicate) +(put 'string-lessp 'byte-optimizer 'byte-optimize-predicate) +(put 'proper-list-p 'byte-optimizer 'byte-optimize-predicate) (put 'logand 'byte-optimizer 'byte-optimize-predicate) (put 'logior 'byte-optimizer 'byte-optimize-predicate) diff --git a/src/fns.c b/src/fns.c index c3202495da..c840019456 100644 --- a/src/fns.c +++ b/src/fns.c @@ -5326,6 +5326,12 @@ syms_of_fns (void) DEFSYM (Qcursor_in_echo_area, "cursor-in-echo-area"); DEFSYM (Qwidget_type, "widget-type"); + DEFSYM (Qpure, "pure"); + DEFSYM (Qside_effect_free, "side-effect-free"); + DEFSYM (Qproper_list_p, "proper-list-p"); + Fput (Qproper_list_p, Qpure, Qt); + Fput (Qproper_list_p, Qside_effect_free, Qt); + DEFVAR_LISP ("overriding-plist-environment", Voverriding_plist_environment, doc: /* An alist that overrides the plists of the symbols which it lists. Used by the byte-compiler to apply `define-symbol-prop' during -- 2.20.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Move-proper-list-p-tests-to-fns-tests.el.patch >From 82399337d891f8c078b78f0de013ba240d1fc236 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Tue, 9 Apr 2019 17:05:27 +0100 Subject: [PATCH 2/2] Move proper-list-p tests to fns-tests.el This follows the move of proper-list-p from lisp/subr.el to src/fns.c in 2018-07-24T15:58:46-07:00!eggert@cs.ucla.edu. * test/lisp/subr-tests.el (subr-tests--proper-list-p): Move from here... * test/src/fns-tests.el (test-proper-list-p): ...to here. --- test/lisp/subr-tests.el | 18 ------------------ test/src/fns-tests.el | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 7465aac5ea..c458eef2f9 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -318,24 +318,6 @@ subr-test--frames-1 (should (eq (string-to-char (symbol-name (gensym))) ?g)) (should (eq (string-to-char (symbol-name (gensym "X"))) ?X))) -(ert-deftest subr-tests--proper-list-p () - "Test `proper-list-p' behavior." - (dotimes (length 4) - ;; Proper and dotted lists. - (let ((list (make-list length 0))) - (should (= (proper-list-p list) length)) - (should (not (proper-list-p (nconc list 0))))) - ;; Circular lists. - (dotimes (n (1+ length)) - (let ((circle (make-list (1+ length) 0))) - (should (not (proper-list-p (nconc circle (nthcdr n circle)))))))) - ;; Atoms. - (should (not (proper-list-p 0))) - (should (not (proper-list-p ""))) - (should (not (proper-list-p []))) - (should (not (proper-list-p (make-bool-vector 0 nil)))) - (should (not (proper-list-p (make-symbol "a"))))) - (ert-deftest subr-tests--assq-delete-all () "Test `assq-delete-all' behavior." (cl-flet ((new-list-fn diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index d6cc99e8e3..6ebab4287f 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el @@ -648,4 +648,22 @@ dot2 (should (equal (list (eq a b) n len) (list t n len)))))))) +(ert-deftest test-proper-list-p () + "Test `proper-list-p' behavior." + (dotimes (length 4) + ;; Proper and dotted lists. + (let ((list (make-list length 0))) + (should (= (proper-list-p list) length)) + (should (not (proper-list-p (nconc list 0))))) + ;; Circular lists. + (dotimes (n (1+ length)) + (let ((circle (make-list (1+ length) 0))) + (should (not (proper-list-p (nconc circle (nthcdr n circle)))))))) + ;; Atoms. + (should (not (proper-list-p 0))) + (should (not (proper-list-p ""))) + (should (not (proper-list-p []))) + (should (not (proper-list-p (make-bool-vector 0 nil)))) + (should (not (proper-list-p (make-symbol "a"))))) + (provide 'fns-tests) -- 2.20.1 --=-=-= Content-Type: text/plain Stefan Monnier writes: >> @@ -1160,8 +1161,8 @@ byte-optimize-set >> make-list make-string make-symbol marker-buffer max member memq min >> minibuffer-selected-window minibuffer-window >> mod multibyte-char-to-unibyte next-window nth nthcdr number-to-string >> - parse-colon-path plist-get plist-member >> - prefix-numeric-value previous-window prin1-to-string propertize >> + parse-colon-path plist-get plist-member prefix-numeric-value >> + previous-window prin1-to-string proper-list-p propertize >> degrees-to-radians >> radians-to-degrees rassq rassoc read-from-string regexp-quote >> region-beginning region-end reverse round > > I think it'd be better to add a `side-effect-free` property rather than > add to this list. We should be moving away from having this list in > byte-opt.el since that info can also be used when byte-opt is not > loaded. Makes sense, how's the attached? Is there a better place to do this than in syms_of_fns? (I followed the example in src/json.c.) >> diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el >> index 8bbe6292d9..0e953dc96b 100644 >> --- a/lisp/emacs-lisp/bytecomp.el >> +++ b/lisp/emacs-lisp/bytecomp.el >> @@ -3566,6 +3566,7 @@ byte-defop-compiler-1 >> >> ;;####(byte-defop-compiler move-to-column 1) >> (byte-defop-compiler-1 interactive byte-compile-noop) >> +(byte-defop-compiler-1 proper-list-p 1) > > I don't think this is needed. Right. For some reason the byte-compiler wasn't complaining about wrong numbers of arguments without this compiler-form, but I can no longer reproduce that. I also attach a second patch which moves the proper-list-p tests to the correct file following the function's rewriting in C. WDYT? Thanks, -- Basil --=-=-=--