[Top][All Lists]

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

Re: continuation?

From: Thien-Thi Nguyen
Subject: Re: continuation?
Date: Sat, 26 Jan 2002 00:37:09 -0800

   From: Seong-Kook Shin <address@hidden>
   Date: Sat, 26 Jan 2002 16:51:06 +0900 (KST)

   (1) What's the exact meaning of `application' in the above
      quotation?  I suppose that meaning might be the same which
      can be found in the Scheme grammer (also found in the book):

           <application> -> (<expression> <expression>*)
                                |                 |
       Right?                   +-----+     +-----+
                                      *     *
yes.  substituting simply, we get: (call/cc P).  this form, when
evaluated, results in the application of call/cc to P.

   (2) What's the exact meaning of *CURRENT* continuation?
      Does it mean the expression that will be evaluate next?
      For example:

             (lambda (k)
               (* 5 (k 4))))

       I think that the `current continuation' of above code
       is "(call/cc (lambda ...))" itself. Right?

no.  here, the cc is the the var K.  "currency" is with respect to the
evaluator, which has encountered the call/cc somehow, perhaps as part of
a (possibly nested) sequence of forms.  in the evaluator's navigation of
these forms to the point of finding the call/cc, it collects state for
accounting and semantic purposes.  this state is curried (of sorts) into
K.  you have probably seen this form of currying before:

(define (add-x x) (lambda (n) (+ x n)))

   (3) What's wrong in this code?

             (lambda (k)
               (* 5 k)))
           => ABORT: (wrong-type-arg)

   In the code of question 2, 3, "call/cc" is an abbreviation of
   "call-with-current-continuation" as you expected.

but what is K?

        The continuation itself is represented by a
        procedure K.  Each time K is applied to a value, it
        returns the value to the continuation of the call/cc

if K is a procedure, how can you multiply it by 5?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]