unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Christopher Cramer <crayc@pyro.net>
Subject: [PATCH] lambda* fails with #:key and rest argument
Date: Thu, 30 May 2002 13:44:11 -0500	[thread overview]
Message-ID: <20020530134411.A882@kiwi.pyrotechnics.com> (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


             reply	other threads:[~2002-05-30 18:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-30 18:44 Christopher Cramer [this message]
2002-06-29 19:44 ` [PATCH] lambda* fails with #:key and rest argument 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020530134411.A882@kiwi.pyrotechnics.com \
    --to=crayc@pyro.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).