The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
My mind and continuations, callcc seen graphically

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eigen Class

Posts: 358
Nickname: eigenclass
Registered: Oct, 2005

Eigenclass is a hardcore Ruby blog.
My mind and continuations, callcc seen graphically Posted: Nov 21, 2005 7:48 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eigen Class.
Original Post: My mind and continuations, callcc seen graphically
Feed Title: Eigenclass
Feed URL: http://feeds.feedburner.com/eigenclass
Feed Description: Ruby stuff --- trying to stay away from triviality.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eigen Class
Latest Posts From Eigenclass

Advertisement

After writing about the relative difficulties of callcc and 2ch, I kept pondering about the nature of the problem with callcc, or more precisely about the process used to solve problems using continuations. By now, most (well, many) people know about the CPS transformation, and callcc as a means to get hold of the implicit continuation ("the rest of the computation"), but we often have a hard time using continuations: there's a large gap between analytical comprehension (understanding code which uses callcc) and the ability to actually synthesize a solution to a problem using callcc.

So I tried to analyze how I solved the original problem, deconstructing the process I didn't consciously think about since I had already internalized it. When trying to solve this, I'm essentially trying to derive the static representation of the program (code) from the desired dynamic behavior. I know the solution is going to look like

        def open_block(fn)
A1        fh = _open(fn)
A2        yield fh
A3        _close(fh)
        end

        def open(fn)
B1        # magic
B2        open_block(fn) do |fh|
B3          # magic
          end
B4        # magic
        end

        def close(fh)
C1        # magic
        end

APP1    fh = open("foo")
APP2    whatever(fh)
APP3    close(fh)
APP4    puts "DONE"
and I want to find how to complete that code so that at run-time it behaves as follows
      code                        "natural" continuation
APP1    fh = open("foo")          B1
  B1        # magic               B2
  B2        open_block(fn)        A1
    A1        fh = _open(fn)      A2
    A2        yield fh            B3
      B3          # magic         A3
--------------------------------------   1st non-local jump
APP2    whatever(fh)              APP3
APP3    close(fh)                 C1
  C1        # magic               APP4
--------------------------------------   2nd non-local jump
    A3        _close(fh)          B4
    B4        # magic             APP2
--------------------------------------   3rd non-local jump
APP4    puts "DONE"

This can be represented graphically as callcc.png


Read more...

Read: My mind and continuations, callcc seen graphically

Topic: Heading to San Francisco, CA. Meet Up? Previous Topic   Next Topic Topic: Rails Enterprise Case Study

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use