[plt-scheme] symbols redefined in SRFIs

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Mon Oct 23 18:33:59 EDT 2006

Robby Findler skrev:
> At Tue, 24 Oct 2006 01:15:46 +0300, "Dan Muresan" wrote:
>> Perhaps you misunderstood me -- I'm not saying that the default
>> mzscheme language should not export the conflicting symbols; I'm
>> suggesting that it should export the SRFI-1 versions directly,
>> avoiding a spurious conflict whenever SRFI-1 is (require)'ed.
> If I were to write a program that used mzscheme's reverse! and worked
> fine, and then I were to add a require in to load in some procedure
> (that, presumably wasn't reverse!) from srfi-1, my old program should
> would (silently) behave differently? That doesn't seem wise.

That's the general problem. Each time a new srfi redefines
a primitive in principle all code needs to be checked to
see if old code still works. It could be done of course,
but resources are limited.

In the particular case of reverse! the code in "misc.ss"

   (define (my-reverse! lis)
     (let lp ((lis lis) (ans '()))
       (if (null-list? lis) ans
         (let ((tail (cdr lis)))
	  (set-cdr! lis ans)
      	  (lp tail lis)))))


Since the loop repeatedly uses null-list? to check
whether the list is a proper or *circular* list, the
runtime time isn't impressive.

(require (prefix srfi1: (lib "1.ss" "srfi")))

(define (test rev!)
   (let ([l (vector->list
             (make-vector 10000000))])
     (time (rev! l))

(test reverse!)

(test srfi1:reverse!)

cpu time: 94 real time: 94 gc time: 0

cpu time: 609 real time: 609 gc time: 0

Jens Axel Søgaard

Posted on the users mailing list.