GNU bug report logs - #13835
[PATCH] Let reverse! accept arbitrary types as second argument (new_tail)

Previous Next

Package: guile;

Reported by: David Kastrup <dak <at> gnu.org>

Date: Wed, 27 Feb 2013 15:42:02 UTC

Severity: normal

Tags: patch

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13835 in the body.
You can then email your comments to 13835 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#13835; Package guile. (Wed, 27 Feb 2013 15:42:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Kastrup <dak <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Wed, 27 Feb 2013 15:42:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: David Kastrup <dak <at> gnu.org>
To: bug-guile <at> gnu.org
Cc: David Kastrup <dak <at> gnu.org>
Subject: [PATCH] Let reverse! accept arbitrary types as second argument
	(new_tail)
Date: Wed, 27 Feb 2013 16:37:21 +0100
There is no reason to restrict the type of the second argument to proper
lists as it is added as last CDR to the list without interpretation.

This allows for stack-depth friendly usage (simplified from an actual
use case that blew up around my ears) like

SCM
my_tree_copy (SCM src)
{
  if (scm_is_pair (src))
    {
      SCM res = SCM_EOL;
      do
        {
          res = scm_cons (my_tree_copy (scm_car (src)), res);
          src = scm_cdr (src);
        }
      while (scm_is_pair (src));
      return scm_reverse_x (res, my_tree_copy (src));
    }
  return src;
}

* libguile/list.c (scm_reverse_x): remove typecheck for 2nd arg
---
 libguile/list.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/libguile/list.c b/libguile/list.c
index 6c8f8be..d30f9e8 100644
--- a/libguile/list.c
+++ b/libguile/list.c
@@ -377,8 +377,6 @@ SCM_DEFINE (scm_reverse_x, "reverse!", 1, 1, 0,
   SCM_VALIDATE_LIST (1, lst);
   if (SCM_UNBNDP (new_tail))
     new_tail = SCM_EOL;
-  else
-    SCM_VALIDATE_LIST (2, new_tail);
 
   while (!SCM_NULL_OR_NIL_P (lst))
     {
-- 
1.7.10.4





Reply sent to Mark H Weaver <mhw <at> netris.org>:
You have taken responsibility. (Thu, 28 Feb 2013 01:53:01 GMT) Full text and rfc822 format available.

Notification sent to David Kastrup <dak <at> gnu.org>:
bug acknowledged by developer. (Thu, 28 Feb 2013 01:53:02 GMT) Full text and rfc822 format available.

Message #10 received at 13835-done <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: David Kastrup <dak <at> gnu.org>
Cc: 13835-done <at> debbugs.gnu.org
Subject: Re: bug#13835: [PATCH] Let reverse! accept arbitrary types as second
	argument (new_tail)
Date: Wed, 27 Feb 2013 20:50:24 -0500
David Kastrup <dak <at> gnu.org> writes:
> There is no reason to restrict the type of the second argument to proper
> lists as it is added as last CDR to the list without interpretation.
>
> This allows for stack-depth friendly usage [...]

Looks good to me.  Applied, thanks!

    Mark




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 28 Mar 2013 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 31 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.