TAILIEUCHUNG - HandBooks Professional Java-C-Scrip-SQL part 25

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 25', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | . Continuations You ve probably played video games. Think of a continuation as a save game feature. As you re playing your game you save your current game. You can feel free to take your chances with the monster control center. If you die you simply restore the game. Said another way a continuation is a snapshot of a point in time. Continuations let you save the system s state in the form of an execution stack in one place and then return to that state on command. Since I ve already introduced Ruby s syntax I ll first show you continuations in Ruby where continuation syntax is clean and precise. Then I ll show you Seaside the most popular continuation-based server in Smalltalk. In Ruby a code block defines the universe for the continuation. You ll use a continuation object to hold the execution state consisting of the execution stack. You ll later invoke a call method on the continuation object to restore the system state replacing the current execution state including the call stack with the one in the continuation object. The call returns execution to the point immediately after the code block. From Ruby s perspective you re conceptually letting your execution state jump back in time. . The Syntax In Ruby you get a continuation by calling the callcc method on Kernel and passing it a code block. This block does nothing with the continuation but print its object identifier irb main 001 0 callcc continuation puts continuation Continuation 0x28c2dd8 This passive little program does more than you think it does. The argument called continuation is a powerful little gem that has the whole execution context with variable values and the entire call stack at the time that you called callcc. Look at it as a saved game or a frozen moment in time. You can return to that moment in time. Specifically Ruby will return to execute the statement immediately after the continuation block by calling the continuation. Here s a trickier continuation example callcc do .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.