From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: To be a list or not Date: Mon, 31 Dec 2007 09:38:44 -0700 Message-ID: References: <477568AC.7090304@gmail.com> <18293.28417.122146.27016@kahikatea.snap.net.nz> <47758120.5000507@gmail.com> <18293.35504.41211.784522@kahikatea.snap.net.nz> <4775925A.6020300@gmail.com> <18293.49293.672805.512265@rgrjr.rgrjr.com> <87odc96waz.fsf@uwakimon.sk.tsukuba.ac.jp> Reply-To: Tom Tromey NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1199120905 12744 80.91.229.12 (31 Dec 2007 17:08:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 31 Dec 2007 17:08:25 +0000 (UTC) Cc: Bob Rogers , "Stephen J. Turnbull" , "Lennart Borgman \(gmail\)" , Emacs Devel To: Andreas Schwab Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 31 18:08:38 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 1J9O7w-0006eK-IS for ged-emacs-devel@m.gmane.org; Mon, 31 Dec 2007 18:08:36 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J9O7a-0003Rd-OB for ged-emacs-devel@m.gmane.org; Mon, 31 Dec 2007 12:08:14 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J9O7X-0003PN-7T for emacs-devel@gnu.org; Mon, 31 Dec 2007 12:08:11 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J9O7V-0003M4-K9 for emacs-devel@gnu.org; Mon, 31 Dec 2007 12:08:10 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J9O7V-0003Lk-Dw for emacs-devel@gnu.org; Mon, 31 Dec 2007 12:08:09 -0500 Original-Received: from mx1.redhat.com ([66.187.233.31]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J9O7V-0005VT-31 for emacs-devel@gnu.org; Mon, 31 Dec 2007 12:08:09 -0500 Original-Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id lBVH86Jm023383; Mon, 31 Dec 2007 12:08:06 -0500 Original-Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lBVH860r031051; Mon, 31 Dec 2007 12:08:06 -0500 Original-Received: from opsy.redhat.com (ton.yyz.redhat.com [10.15.16.15]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lBVH85cB009941; Mon, 31 Dec 2007 12:08:05 -0500 Original-Received: by opsy.redhat.com (Postfix, from userid 500) id 42372C8803B; Mon, 31 Dec 2007 09:38:44 -0700 (MST) X-Attribution: Tom In-Reply-To: (Andreas Schwab's message of "Sun\, 30 Dec 2007 00\:22\:44 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.990 (gnu/linux) X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) 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:85746 Archived-At: >>>>> "Andreas" == Andreas Schwab writes: Andreas> Tom Tromey writes: Andreas> + return tail == Qnil ? Qt : Qnil; Andreas> NILP (tail) Thanks, I didn't know about that. BTW I see a number of EQ(...,Qnil) comparisons in the current code. Here's a revised patch. I considered Stephen's suggestion of having two loops, but I think it probably is not worthwhile. Tom 2007-12-31 Tom Tromey * lisp.h (Ftrue_list_p): Declare. * data.c (Ftrue_list_p): New function. (syms_of_data): Update. Index: data.c =================================================================== RCS file: /sources/emacs/emacs/src/data.c,v retrieving revision 1.287 diff -u -r1.287 data.c --- data.c 22 Nov 2007 20:29:48 -0000 1.287 +++ data.c 31 Dec 2007 17:04:24 -0000 @@ -285,6 +285,28 @@ return Qnil; return Qt; } + +DEFUN ("true-list-p", Ftrue_list_p, Strue_list_p, 1, 1, 0, + doc: /* Return t if OBJECT is an acyclic, nil-terminated list. */) + (object) + Lisp_Object object; +{ + Lisp_Object tail, halftail; + int len = 0; + + /* halftail is used to detect circular lists. */ + halftail = object; + for (tail = object; CONSP (tail); tail = XCDR (tail)) + { + if (EQ (tail, halftail) && len != 0) + return Qnil; + ++len; + if ((len & 1) == 0) + halftail = XCDR (halftail); + } + + return NILP (tail) ? Qt : Qnil; +} DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, doc: /* Return t if OBJECT is a symbol. */) @@ -3291,6 +3313,7 @@ defsubr (&Stype_of); defsubr (&Slistp); defsubr (&Snlistp); + defsubr (&Strue_list_p); defsubr (&Sconsp); defsubr (&Satom); defsubr (&Sintegerp); Index: lisp.h =================================================================== RCS file: /sources/emacs/emacs/src/lisp.h,v retrieving revision 1.603 diff -u -r1.603 lisp.h --- lisp.h 22 Nov 2007 01:01:26 -0000 1.603 +++ lisp.h 31 Dec 2007 17:05:52 -0000 @@ -2205,6 +2208,7 @@ EXFUN (Fconsp, 1); EXFUN (Fatom, 1); EXFUN (Fnlistp, 1); +EXFUN (Ftrue_list_p, 1); EXFUN (Fintegerp, 1); EXFUN (Fnatnump, 1); EXFUN (Fsymbolp, 1);