Monday 15 August 2011

functional programming - Can somebody please explain this continuation in scheme? -


I am learning continuity but I can not wrap my head around this code. Why does it go in infinite loop?

  (but (cont #f)) (call / cc (lambda (k) (set! Cont k)) (cont #f))  
< Line divider:

  • We define local variables
  • We call some lambda functions with the current continuity, that is, we are continuing the lambda function as the argument to the current argument. Current continuity is a function of argument 1, this argument is then used as the "return value" of call / cc (and finally it has been ignored).
  • Then after a few things in our case with << Code> (Lambda (call / CC-retal) (let's) (call / CC-Rated (cont #f)) . We set the cont value for this continuity. Return cc / cc .
  • Since cont is now a function that represents continuity, and its argument is "call / cc return value", we call that function, the argument is ignored, and Visit us at (cont #f)
  • >


No comments:

Post a Comment