unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#13835: [PATCH] Let reverse! accept arbitrary types as second argument (new_tail)
@ 2013-02-27 15:37 David Kastrup
  2013-02-28  1:50 ` Mark H Weaver
  0 siblings, 1 reply; 2+ messages in thread
From: David Kastrup @ 2013-02-27 15:37 UTC (permalink / raw)
  To: 13835; +Cc: David Kastrup

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






^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#13835: [PATCH] Let reverse! accept arbitrary types as second argument (new_tail)
  2013-02-27 15:37 bug#13835: [PATCH] Let reverse! accept arbitrary types as second argument (new_tail) David Kastrup
@ 2013-02-28  1:50 ` Mark H Weaver
  0 siblings, 0 replies; 2+ messages in thread
From: Mark H Weaver @ 2013-02-28  1:50 UTC (permalink / raw)
  To: David Kastrup; +Cc: 13835-done

David Kastrup <dak@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-28  1:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-27 15:37 bug#13835: [PATCH] Let reverse! accept arbitrary types as second argument (new_tail) David Kastrup
2013-02-28  1:50 ` Mark H Weaver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).