[gambit-list] gcc stage timing

Christian christian at pflanze.mine.nu
Tue Oct 17 14:37:01 EDT 2006


At 13:13 Uhr -0400 17.10.2006, Lang Martin wrote:
>That's just the one call to gensym, which vaguely seems like the most
>expensive part of doing it this way

You could move that outside the call path:

(define make-lazy
   (let* ((nothing (gensym))
          (exit (lambda () nothing)))
     (lambda (generator)
        (let lp ()
           (delay
              (let ((value (generator exit)))
                 (if (eq? value nothing)
                    '()
                    (cons value
                          (lp))))))))

>, and should be as correct. Could
>write a generator to break it, but I don't suppose it'd happen
>accidently.

(The generator has to call the exit function in tail position now. 
Maybe better just feed it the nothing value -- or move the nothing 
value to the toplevel and export it to users, so the generator can 
become a thunk.)

Christian.



More information about the Gambit-list mailing list