From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.lisp.guile.bugs Subject: bug#17485: [PATCH 2/3] Rewrite take-right, drop-right, drop-right! Date: Sat, 20 Sep 2014 17:15:23 +0200 Message-ID: <87wq8ypblg.fsf@fencepost.gnu.org> References: <1401821778-19972-1-git-send-email-dak@gnu.org> <1401821778-19972-2-git-send-email-dak@gnu.org> <87k34yl4s3.fsf@yeeloong.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1411226240 3858 80.91.229.3 (20 Sep 2014 15:17:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Sep 2014 15:17:20 +0000 (UTC) Cc: 17485@debbugs.gnu.org To: Mark H Weaver Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sat Sep 20 17:17:13 2014 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XVMPR-0007z5-DD for guile-bugs@m.gmane.org; Sat, 20 Sep 2014 17:17:13 +0200 Original-Received: from localhost ([::1]:34991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XVMPQ-0000Us-Sl for guile-bugs@m.gmane.org; Sat, 20 Sep 2014 11:17:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XVMPM-0000GX-LZ for bug-guile@gnu.org; Sat, 20 Sep 2014 11:17:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XVMPL-0003WW-KK for bug-guile@gnu.org; Sat, 20 Sep 2014 11:17:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XVMPL-0003Vg-Gq for bug-guile@gnu.org; Sat, 20 Sep 2014 11:17:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XVMPG-0006gq-2f for bug-guile@gnu.org; Sat, 20 Sep 2014 11:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: David Kastrup Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 20 Sep 2014 15:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17485 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 17485-submit@debbugs.gnu.org id=B17485.141122619125665 (code B ref 17485); Sat, 20 Sep 2014 15:17:02 +0000 Original-Received: (at 17485) by debbugs.gnu.org; 20 Sep 2014 15:16:31 +0000 Original-Received: from localhost ([127.0.0.1]:46805 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XVMOk-0006ft-IN for submit@debbugs.gnu.org; Sat, 20 Sep 2014 11:16:30 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:48309) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XVMOi-0006fj-82 for 17485@debbugs.gnu.org; Sat, 20 Sep 2014 11:16:29 -0400 Original-Received: from localhost ([127.0.0.1]:55616 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XVMOh-00037R-3y; Sat, 20 Sep 2014 11:16:27 -0400 Original-Received: by lola (Postfix, from userid 1000) id 6EC99E17F6; Sat, 20 Sep 2014 17:15:23 +0200 (CEST) In-Reply-To: <87k34yl4s3.fsf@yeeloong.lan> (Mark H. Weaver's message of "Sat, 20 Sep 2014 10:56:12 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7560 Archived-At: Mark H Weaver writes: > David Kastrup writes: > >> * module/srfi/srfi-1.scm (take-right, drop-right, drop-right!): The >> definitions tended to be overly complicate and/or rely on pushing >> material on the VM stack, detrimental to scalability for Guile 2.0 and >> also worse for performance. >> >> The changed definitions lead to different, more accurate exceptions >> being raised. They rely on length+ returning the length of dotted >> lists, behavior that is not specified by the SRFI-1 definition but >> available in GUILE. > > Your patches look good to me, except that we can't change 'length+' as > you propose. Instead I'd like to add a lax variant of 'length+' with a > different name, and use that. > > I can take care of doing this myself, and will of course still credit > you in whatever manner you prefer, but I've run into a legal problem: we > don't currently have copyright papers for you on file. Are you willing > to file copyright papers for GUILE? No problems with that. Standard request-assign? At any rate, here is what I would suggest to create: a function min-length receiving a list of lists (possibly as separate arguments via a rest argument). It will return the number of times one can do cdr on every of the given arguments until at least one of them turns into a list end with nothing turning into anything but a pair or a list end. That would allow dotted lists as long as they are longer than any non-dotted list. It would still flag when scalars are being used instead of dotted or undotted lists, the case you are worried about. That would remain in the spirit of allowing lists of different length as well as infinite lists, basically "as long as the list part matching the shortest finite list is usable, let's take it". While it would not make much sense to actually feed dotted lists into it (as they will never be usable completely), it would speed up figuring the minimum list length since there is no point doing cdr 50 times on list 3 when list 1 has already been tested for being of length 10. -- David Kastrup