CSE 130 Lecture Notes - Lecture 15: If And Only If, Nested Function, Firstclass

77 views5 pages

Document Summary

Ex: a c fs. readfile( blah, callback ); r. Cooperative multi-threading (in contrast to preemptive multi-threading - stops processes whether you want to or not) We yield() - explicitly tell os or runtime the state the save and how to restore. To examine the state of the program (memory) Want to be able to keep going - can continue running the program (have continuation to rest of program!) Consider ( 2*x + 1/y ) * 2: multiply 2 and x, divide 1 by y, add a and b, multiply c and 2. Let cont = curres => (previous + curres) * 2. Current computation cont( 1 / y ) Node. js example const data = fs. readfilesync( myfile. txt") console. log(data); processdata(data); continuation. Explicit continuation (what you have to do today!) fs. readfile( myfile. txt", callback) Call/cc (call w/ current continuation) is used to call a function and give it the current continuation. We want to know where to continue if we got an error!

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers