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

Re: good pictures vs. good stories (was: Re: CPS in Parrot)



 > No continuations to places [2] or [4] are created, because call/cc2
 > and call/cc4 only get continuations as arguments; they never get
 > call/cc as an argument.

How does this reconcile with the actual evaluation results in
different scheme implementations, as shown below?  In those
implementations that evaluate arguments in the left-to-right order, as
God prescribed, this is what actually happens:

Suppose I define

(define c1
  (lambda (x)
    (display 'c1)
    (newline)
    (call-with-current-continuation x)))

with c2, c3, and c4 defined in a similar manner.

Here's what Guile makes of it:

    $ guile
    guile> ((c1 c2) (c3 c4))
    c1
    c2
    c3
    c4
    c3
    c4
    c3
    ...
    standard input:16:5: In procedure newline in expression (newline):
    standard input:16:5: User interrupt
    c3
    ABORT: (signal)

    Type "(backtrace)" to get more information.


Here's MzScheme:

    $ mzscheme
    Welcome to MzScheme version 203, Copyright (c) 1995-2002 PLT
    > ((c1 c2) (c3 c4))
    c1
    c2
    c3
    c4
    c3
    c4
    c3
    c4
    ...
    user break


The MIT/GNU Scheme evaluates stuff right to left. Here's what happens:

    $ scheme
    Scheme Microcode Version 14.9
    MIT Scheme running under GNU/Linux
    Type `^C' (control-C) followed by `H' to obtain information about
    interrupts.

    Scheme saved on Monday June 17, 2002 at 10:03:44 PM
      Release 7.7.1
      Microcode 14.9
      Runtime 15.1

    1 ]=> ((c1 c2) (c3 c4))
    c3
    c4
    c1
    c2
    c1
    c2
    c1
    c2
    c1
    ...
    c1
    ;Quit!