unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* list versus apply
@ 2005-04-20 22:22 Kevin Ryde
  2005-04-22 23:45 ` Kevin Ryde
  2005-06-05 17:30 ` Marius Vollmer
  0 siblings, 2 replies; 6+ messages in thread
From: Kevin Ryde @ 2005-04-20 22:22 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 267 bytes --]

Looks like list doesn't produce a new list when called through apply,

	(define x '(1 2 3))
	(define y (apply list x))
	(eq? x y)
	=> #t

I'm looking at the fix below.  This removes the C level scm_list, but
that should be ok, it's not documented and does nothing.



[-- Attachment #2: list.c.list.diff --]
[-- Type: text/plain, Size: 791 bytes --]

--- list.c.~1.58.2.7.~	2004-05-02 07:19:23.000000000 +1000
+++ list.c	2005-04-20 16:31:40.725063792 +1000
@@ -117,17 +117,6 @@
 }
 
 
-SCM_DEFINE (scm_list, "list", 0, 0, 1, 
-           (SCM objs),
-	    "Return a list containing @var{objs}, the arguments to\n"
-	    "@code{list}.")
-#define FUNC_NAME s_scm_list
-{
-  return objs;
-}
-#undef FUNC_NAME
-
-
 #if (SCM_DEBUG_DEPRECATED == 0)
 
 SCM_REGISTER_PROC (s_list_star, "list*", 1, 0, 1, scm_cons_star);
@@ -547,6 +536,13 @@
 }
 #undef FUNC_NAME
 
+
+SCM_PROC (s_list, "list", 0, 0, 1, scm_list_copy);
+SCM_SNARF_DOCS (register, scm_list_copy, "list", (SCM objs), 0, 0, 1,
+                "Return a list containing @var{objs}, the arguments to\n"
+                "@code{list}.")
+
+
 \f
 /* membership tests (memq, memv, etc.) */ 
 

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

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

* Re: list versus apply
  2005-04-20 22:22 list versus apply Kevin Ryde
@ 2005-04-22 23:45 ` Kevin Ryde
  2005-06-05 17:30 ` Marius Vollmer
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Ryde @ 2005-04-22 23:45 UTC (permalink / raw)


I wrote:
>
> 	(define x '(1 2 3))
> 	(define y (apply list x))
> 	(eq? x y)
> 	=> #t

Actually, I see in the head this happens under the debugging evaluator
but not the normal one.  I made my change because it fixes a bug in
1.6 and the head, but maybe there's something fishy between debug and
normal in the head.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


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

* Re: list versus apply
  2005-04-20 22:22 list versus apply Kevin Ryde
  2005-04-22 23:45 ` Kevin Ryde
@ 2005-06-05 17:30 ` Marius Vollmer
  2005-06-05 20:37   ` Kevin Ryde
  1 sibling, 1 reply; 6+ messages in thread
From: Marius Vollmer @ 2005-06-05 17:30 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> Looks like list doesn't produce a new list when called through apply,
>
> 	(define x '(1 2 3))
> 	(define y (apply list x))
> 	(eq? x y)
> 	=> #t

Is it required to make a copy in this situation?  I thought that

  (define (list . args) args)

is an acceptable definition of list.  Is it not?

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


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

* Re: list versus apply
  2005-06-05 17:30 ` Marius Vollmer
@ 2005-06-05 20:37   ` Kevin Ryde
  2005-06-05 21:11     ` Marius Vollmer
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2005-06-05 20:37 UTC (permalink / raw)
  Cc: guile-devel

Marius Vollmer <mvo@zagadka.de> writes:
>
>   (define (list . args) args)
>
> is an acceptable definition of list.  Is it not?

Yep, because args is of course a fresh list when calling a lambda, but
it looks like primitives (C code) aren't called with a copied list
like that.

(I guess having primitives like that makes some sense, only a few are
interested in modifying or re-using their input "rest" list.)


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


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

* Re: list versus apply
  2005-06-05 20:37   ` Kevin Ryde
@ 2005-06-05 21:11     ` Marius Vollmer
  2005-06-05 21:21       ` Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Marius Vollmer @ 2005-06-05 21:11 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> Marius Vollmer <mvo@zagadka.de> writes:
>>
>>   (define (list . args) args)
>>
>> is an acceptable definition of list.  Is it not?
>
> Yep, because args is of course a fresh list when calling a lambda, but
> it looks like primitives (C code) aren't called with a copied list
> like that.

Ahh, I see.  R5RS says: "The value stored in the binding of the last
variable will be a newly allocated list of the actual arguments..."  I
think I was confusing this with Common Lisp, which says: "The value of
a rest parameter is permitted, but not required, to share structure
with the last argument to apply."

> (I guess having primitives like that makes some sense, only a few are
> interested in modifying or re-using their input "rest" list.)

We need to document this difference between Scheme functions and C
primitives, I'd say.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


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

* Re: list versus apply
  2005-06-05 21:11     ` Marius Vollmer
@ 2005-06-05 21:21       ` Kevin Ryde
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Ryde @ 2005-06-05 21:21 UTC (permalink / raw)
  Cc: guile-devel

Marius Vollmer <mvo@zagadka.de> writes:
>
> We need to document this difference between Scheme functions and C
> primitives, I'd say.

Yep, I added to scm_c_define_gsubr to say what a primitive should
do/expect.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


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

end of thread, other threads:[~2005-06-05 21:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-20 22:22 list versus apply Kevin Ryde
2005-04-22 23:45 ` Kevin Ryde
2005-06-05 17:30 ` Marius Vollmer
2005-06-05 20:37   ` Kevin Ryde
2005-06-05 21:11     ` Marius Vollmer
2005-06-05 21:21       ` Kevin Ryde

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