[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Topes



   Date:     Wed, 5 May 93 12:24:26 MET DST
   From: "J. A. Durieux" <xerox@cs.vu.nl>

   (2) I also understand that "load" is not required to be tail-recursive, but
       since its return value is unspecified, it is not precluded from being
       that either.

I suggested (before the last meeting) that the definition of LOAD be
changed so that the value of the last form in the file be returned.
This was not adopted by the committee.

       But *is* there a way to catch a continuation that does not point back
       to the file?

If you want to do this entirely from the file being loaded, it is not
possible in a way that is guaranteed to work in all R4RS compliant
implementations.

But you could redefine LOAD to dynamically bind a variable, say
*load-continuation* to the LOAD's continuation.

(define *load-continuation* #f)

(define load
  (let ((load load))
    (lambda (file)
      (call-with-current-continuation
       (lambda (cont)
	 (let* ((swap-lc (lambda ()
			   (define old-lc *load-continuation*)
			   (set! *load-continuation* cont)
			   (set! cont old-lc))))
	   (dynamic-wind
	    swap-lc
	    (lambda () (load file))
	    swap-lc)))))))