Continuation

Continuation

From Wikipedia, the free encyclopedia

Jump to: navigation , search

 

In computing and programming , a continuation is an abstract representation of the control state , or the "rest of computation" or "rest of code to be executed". This is closely linked with what part of the program you are in: which function and which line is being executed. The "current continuation " or "continuation of the computation step" are the instructions that will be executed after the current line of code is executed.


The term continuations can also be used to refer to first-class continuations , which are constructs that give a programming language the ability to save the execution state at any point and return to that point at a later point in the program.


Programs must allocate space in memory for the variables its functions use. Most programming languages use a call stack for storing the variables needed because it allows for fast and simple allocating and automatic deallocation of memory. There are also programming languages that use a heap for this, which allows for flexibility but with a higher cost for allocating and deallocating memory. These two different implementations both have benefits and drawbacks in the context of continuations.[ 1]


Almost all languages have a means for manipulating the order of execution steps (i.e. manipulating the continuation of a computation step). The goto is the most basic form of this. Control structures like if statements , loops , return statements , break statements , and exit are more structured (and limited) ways to manipulate the order of executing instructions and are essentially limited goto statements.


More complex constructs exist as well. For example in C , setjmp can be used to jump from the middle of one function to another function, provided the second function is lower on the stack (if it is waiting for the first function to return, possibly among others). Other more complex examples include coroutines in Simula 67 , tasklets in Stackless Python , generators Icon and Python , continuations in Scala (starting in 2.8), fibers in Ruby (starting in 1.9.1), the backtracking mechanism in Prolog , and threads .  

 

Read More...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值