March 21th Wednesday (三月 二十一日 水曜日)
来源:互联网 发布:网络交换器什么牌子好 编辑:程序博客网 时间:2024/05/05 13:32
(call-with-current-continuation proc)
Proc must be a procedure of one argument. The procedure call-with-current-continuation (which is the
same as the procedure call/cc) packages the current continuation as an “escape procedure” and passes
it as an argument to proc. The escape procedure is a Scheme procedure that, if it is later called,
will abandon whatever continuation is in effect at that later time and will instead use the continuation that was in effect when the escape procedure was created. Calling the escape procedure
may cause the invocation of before and after thunks installed using dynamic-wind.
The escape procedure accepts the same number of arguments as the continuation of the original call to call-with-current-continuation. The escape procedure that is passed to proc has unlimited extent
just like any other procedure in Scheme. It may be stored in variables or data structures and may be called as many times as desired.
A common use of call-with-current-continuation is for structured, non-local exits from loops or
procedure bodies, but in fact call-with-current-continuation is useful for implementing a wide
variety of advanced control structures.
Whenever a Scheme expression is evaluated there is a continuation wanting the result of the
expression. The continuation represents an entire (default) future for the computation. Most
of the time the continuation includes actions specified by user code, as in a continuation that will
take the result, multiply it by the value stored in a local variable, add seven, and store the
result in some other variable. Normally these ubiquitous continuations are hidden behind the scenes
and programmers do not think much about them. On rare occasions, however, a programmer may need to deal with continuations explicitly. The call-with-current-continuation procedure allows Scheme
programmers to do that by creating a procedure that acts just like the current continuation.
Most programming languages incorporate one or more specialpurpose escape constructs with names like exit, return, or even goto. In 1965, however, Peter Landin [29] invented a general purpose escape
operator called the J-operator. John Reynolds [38] described a simpler but equally powerful
construct in 1972. The catch special form described by Sussman and Steele in the 1975 report on Scheme is exactly the same as Reynolds’s construct, though its name came from a less general construct in MacLisp. Several Scheme implementors noticed that the full power of the catch construct
could be provided by a procedure instead of by a special syntactic construct, and the name call-with-current-continuation was coined in 1982. This name is descriptive, but opinions differ on the merits
of such a long name, and some people use the name call/cc instead.
(values obj . . .)
Delivers all of its arguments to its continuation. The values procedure might be defined as
follows:
(define (values . things)
(call-with-current-continuation
(lambda (cont) (apply cont things))))
- March 21th Wednesday (三月 二十一日 水曜日)
- 2009 March 11th Wednesday (三月 十一日 水曜日)
- March 28th Wednesday (三月 二十八日 水曜日)
- 2009 March 25th Wednesday (三月 二十五日 水曜日)
- March 14th Wednesday (三月 十四日 水曜日)
- 2008 March 5th Wednesday (三月 五日 水曜日)
- 2009 March 4th Wednesday (三月 四日 水曜日)
- 2009 March 18th Wednesday (三月 十八日 水曜日)
- 2008 March 26th Wednesday (三月 二十六日 水曜日)
- March 7th Wednesday (三月 七日 水曜日)
- 2008 March 21th Friday (三月 二十一日 金曜日)
- January 21th Wednesday 2009 (一月 二十一日 水曜日)
- 2008 March 12th Wednesday (三月 十三日 水曜日
- 2008 March 19th Wednesday (三月 十九日 水曜日)
- 2008 March 11th Tuesday (三月 十一日 火曜日)
- 2009 March 24th Tuesday (三月 二十四日 火曜日)
- 2008 May 21th Wednesday (五月 二十一日 水曜日)
- Aprial 11th Wednesday (四月 十一日 水曜日)
- March 15th Thursday (三月 十五日 木曜日)
- 如何实现公司软件产品保密
- March 16th Friday (三月 十六日 金曜日)
- March 19th Monday (三月 十九日 月曜日)
- March 20th Tuesday (三月 二十日 火曜日)
- March 21th Wednesday (三月 二十一日 水曜日)
- 项目团队管理问题
- March 22th Thursday (三月 二十二日 木曜日)
- March 23th Friday (三月 二十三日 金曜日)
- March 26th Monday (三月 二十六日 月曜日)
- tomcat配置技巧
- IT项目管理经验分享
- sql2000挂起无法安装的问题
- 图像编程的若干常用操作(旋转,透明等)