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: Sat, 29 Dec 2007 15:44:29 -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 1198970045 17633 80.91.229.12 (29 Dec 2007 23:14:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Dec 2007 23:14:05 +0000 (UTC) Cc: "Lennart Borgman \(gmail\)" , Bob Rogers , Emacs Devel To: "Stephen J. Turnbull" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 30 00:14:18 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 1J8ksj-0003lB-9x for ged-emacs-devel@m.gmane.org; Sun, 30 Dec 2007 00:14:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J8ksN-0001sq-Ua for ged-emacs-devel@m.gmane.org; Sat, 29 Dec 2007 18:13:55 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J8ksC-0001je-1u for emacs-devel@gnu.org; Sat, 29 Dec 2007 18:13:44 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J8ksB-0001ii-E2 for emacs-devel@gnu.org; Sat, 29 Dec 2007 18:13:43 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J8ksB-0001iV-73 for emacs-devel@gnu.org; Sat, 29 Dec 2007 18:13:43 -0500 Original-Received: from mx1.redhat.com ([66.187.233.31]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J8ksA-0003pm-Qg for emacs-devel@gnu.org; Sat, 29 Dec 2007 18:13:42 -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 lBTNDftl020737; Sat, 29 Dec 2007 18:13:41 -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 lBTNDfgq018260; Sat, 29 Dec 2007 18:13:41 -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 lBTNDev2030734; Sat, 29 Dec 2007 18:13:40 -0500 Original-Received: by opsy.redhat.com (Postfix, from userid 500) id E67CFC8803B; Sat, 29 Dec 2007 15:44:29 -0700 (MST) X-Attribution: Tom In-Reply-To: <87odc96waz.fsf@uwakimon.sk.tsukuba.ac.jp> (Stephen J. Turnbull's message of "Sun\, 30 Dec 2007 06\:11\:16 +0900") 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:85644 Archived-At: >>>>> "Stephen" == Stephen J Turnbull writes: Stephen> But please call it `true-list-p', which is the name of the Stephen> similar XEmacs built-in. Here's one stab at it. This is basically lifted from safe-length. I tested it with various inputs. Is there an Emacs test suite? I'd be happy to put tests there, if there is one. Tom ChangeLog: 2007-12-29 Tom Tromey * lisp.h (Ftrue_list_p): Declare. * data.c (Ftrue_list_p): New function. (syms_of_data): Update. 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 29 Dec 2007 23:10:43 -0000 @@ -2205,6 +2205,7 @@ EXFUN (Fconsp, 1); EXFUN (Fatom, 1); EXFUN (Fnlistp, 1); +EXFUN (Ftrue_list_p, 1); EXFUN (Fintegerp, 1); EXFUN (Fnatnump, 1); EXFUN (Fsymbolp, 1); 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 29 Dec 2007 23:10:44 -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 tail == Qnil ? 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);