[plt-scheme] should `map' reuse cons cells?

From: Doug Orleans (dougo at place.org)
Date: Wed May 26 16:15:25 EDT 2004

According to the SRFI-1 notes about its reference implementation:

  Functions reuse longest common tails from input parameters to
  construct their results where possible.

Shouldn't that mean that the following should be true?

  > (define l (list 1 2 3))
  > (eq? l (map identity l))
  #f

Which makes me wonder whether such an implementation of `map' would
even be allowed...  R5RS appears not to specify whether `map' is
allowed to reuse its input cons cells, which I would interpret to mean
that code that relies on either behavior is non-compliant.  But maybe
there's something in the spec that I'm missing?

Anyway, I think it would be nice for PLT's implementation of `map' to
reuse longest common tails.  (Or at least PLT's implementation of
SRFI-1's version of `map'.)  Thoughts?

--dougo at place.org


Posted on the users mailing list.