unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] lambda* fails with #:key and rest argument
@ 2002-05-30 18:44 Christopher Cramer
  2002-06-29 19:44 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 6+ messages in thread
From: Christopher Cramer @ 2002-05-30 18:44 UTC (permalink / raw)


Here's the problem:

guile> (use-modules (ice-9 optargs))
guile> (lambda* (#:key foo . bar) #t)
/usr/local/share/guile/1.5.6/ice-9/optargs.scm:371:24: In procedure list-copy in expression (list-copy arglist):
/usr/local/share/guile/1.5.6/ice-9/optargs.scm:371:24: Wrong type argument in position 1: (#:key foo . bar)
ABORT: (wrong-type-arg)

Basically, there's a part where it tries to copy an improper list
with list-copy, which doesn't work. The solution lies in creating
improper-list-copy. At first I just put a new function in list.c (which
is trivial: copy scm_list_copy to scm_improper_list_copy and change
SCM_VALIDATE_LIST to SCM_VALIDATE_CONS), but then I figured I wanted
it fixed in stable, and we probably don't want a new public procedure at
this point.

Index: ice-9/optargs.scm
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/ice-9/optargs.scm,v
retrieving revision 1.14.2.3
diff -u -r1.14.2.3 optargs.scm
--- ice-9/optargs.scm	18 Oct 2001 19:41:08 -0000	1.14.2.3
+++ ice-9/optargs.scm	30 May 2002 18:26:05 -0000
@@ -368,7 +368,7 @@
      ((null? arglist) (cont '() '() '() #f #f))
      ((not (pair? arglist)) (cont '() '() '() #f arglist))
      ((not (list? arglist))
-	  (let* ((copy (list-copy arglist))
+	  (let* ((copy (improper-list-copy arglist))
 		 (lp (last-pair copy))
 		 (ra (cdr lp)))
 	    (set-cdr! lp '())
@@ -387,7 +387,16 @@
 
   (parse-rest arglist cont))
 
-
+(define (improper-list-copy l)
+    (let ((out '()))
+	(let loop ((in l) (prev '()))
+	    (if (pair? in)
+		(let ((cur (cons (car in) (cdr in))))
+		    (if (null? prev)
+			(set! out cur)
+			(set-cdr! prev cur))
+		    (loop (cdr in) cur))
+		out))))
 
 ;; define* args . body
 ;; define*-public args . body

-- 
Christopher Cramer <crayc@pyro.net> <http://www.pyro.net/~crayc/>
On résiste à l'invasion des armées; on ne résiste pas à l'invasion
des idées.  -- Victor Hugo

_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile


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

end of thread, other threads:[~2002-07-16 22:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-30 18:44 [PATCH] lambda* fails with #:key and rest argument Christopher Cramer
2002-06-29 19:44 ` Thien-Thi Nguyen
2002-06-30 19:19   ` Dirk Herrmann
2002-07-07 22:37     ` Marius Vollmer
2002-07-08 18:16       ` Marius Vollmer
2002-07-16 22:44         ` Dirk Herrmann

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).