This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How often are continuations created?


Keisuke Nishida <kxn30@po.cwru.edu> writes:

> My current compiler does it:
> 
>   (do ((i 0 (1+ i)))
>       ((= i N))
>    (vector-set! v i (magic-computation i)))  =>


> Since magic-computation is a procedure, %call creates a new frame for
> it.  `i' is still a local variable because magic-computation cannot
> refer to it.  Is there any problem with this?

Well, suppose magic computation, when first invoked, calls call/cc and
passes it out through some global, then just returns and does a NOP
until the loop exits

(sample:

	(define magic-computation
	  (let ((capture #t)
	     (if (capture)
		(begin
		   (set! capture #f)
		   (set! some-cont (call/cc (lambda (cont) cont))))))))

)

Then, when you invoke some-cont, it will return from magic-computation
and redo the loop - except that the value of i will be 0, when it
should be N.

-- 
How to eff the ineffable?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]