延续的基本概念 [英] The fundamental concept of continuations

查看:59
本文介绍了延续的基本概念的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我再次感到很沮丧,因为我遇到了一个基本上全新的概念,即我总是闻所未闻。它甚至不在保罗·格雷厄姆的书中,我在那里学习了一部分Lisp。它在Marc Feeley的视频中。


任何人都可以解释:


(1)其来源

(2)它在emacs中的语法和语义lisp,常见的lisp,scheme

(3)它是否存在于python和java中?

(4)它在汇编中的实现。例如,

指针从根本上来自间接寻址并且没有什么新东西。

那么你如何兼顾PC来实现它。

(5)它如何与一个函数或子程序进行比较和优于

调用。它是如何区别的。


非常感谢。


(6)任何可读性很好的参考资料都能清楚地解释它?

Again I am depressed to encounter a fundamentally new concept that I
was all along unheard of. Its not even in paul graham''s book where i
learnt part of Lisp. Its in Marc Feeley''s video.

Can anyone explain:

(1) its origin
(2) its syntax and semantics in emacs lisp, common lisp, scheme
(3) Is it present in python and java ?
(4) Its implementation in assembly. for example in the manner that
pointer fundamentally arises from indirect addressing and nothing new.
So how do you juggle PC to do it.
(5) how does it compare to and superior to a function or subroutine
call. how does it differ.

Thanks a lot.

(6) any good readable references that explain it lucidly ?

推荐答案

在文章< 11 ********************** @ 57g2000hsv中。 Google网上论坛。 com>,
gn*******@gmail.com 写道:
In article <11**********************@57g2000hsv.googlegroups. com>,
gn*******@gmail.com wrote:

再次,我很沮丧地遇到了一个基本上全新的概念,即我总是闻所未闻的

Again I am depressed to encounter a fundamentally new concept that I
was all along unheard of.



不要对此感到沮丧。那里有无数的概念

你还没有听说过。

Don''t be depressed about that. There are countless concepts out there
they you haven''t yet heard of.


它甚至不在保罗·格雷厄姆的书中哪里我

学到了Lisp的一部分。它在Marc Feeley的视频中。


任何人都可以解释:


(1)其来源
Its not even in paul graham''s book where i
learnt part of Lisp. Its in Marc Feeley''s video.

Can anyone explain:

(1) its origin



Lambda演算。而不是函数A返回其调用者,

调用者提供了一个额外的参数(continuation),这是一个由A和A调用的函数B.的结果。在纯粹的延续

风格中编码,没有任何东西返回结果。


很容易将正常的函数式lambda

微积分机械转换为continuation-style,但事实并非如此。

Lambda calculus. Instead of function A returning to its caller, the
caller provides an additional argument (the "continuation") which is a
function B to be called by A with A''s result(s). In pure "continuation
style" coding, nothing ever "returns" a result.

It is easy to mechanically transform normal function-style lambda
calculus into continuation-style, but the reverse is not so.


(2)它在emacs中的语法和语义lisp,常见的lisp,scheme

(3)它是否存在于python和java中?
(2) its syntax and semantics in emacs lisp, common lisp, scheme
(3) Is it present in python and java ?



Java,等等。例如,Run界面。

Python,我不知道。

Java, sort of. For example, the Run interface.
Python, I don''t know.


(4)它在汇编中的实现。例如,

指针从根本上来自间接寻址并且没有什么新东西。

那么你如何兼顾PC来做到这一点。
(4) Its implementation in assembly. for example in the manner that
pointer fundamentally arises from indirect addressing and nothing new.
So how do you juggle PC to do it.



你可以拥有一个spaghetti stack,或者在堆中保持连续数据结构


You can have a "spaghetti stack", or keep continuation data-structures
in the heap.


(5)它如何与一个函数或子程序进行比较和优于

调用。它有什么不同。
(5) how does it compare to and superior to a function or subroutine
call. how does it differ.



这听起来像是家庭作业。到目前为止你有什么用?

This sounds like homework. What do you have so far?


非常感谢。


(6)任何可读性很好的参考文献都能清楚地解释它?
Thanks a lot.

(6) any good readable references that explain it lucidly ?



Google?


-

---------- -----------------

| BBB b \芭芭拉在LivingHistory停止合作停止英国

| B B aa rrr b |

| BBB a a b bbb | Quidquid latine格言坐,

| B B a a b b b | altum viditur。

| BBB aa ar bbb |

-----------------------------

Google?

--
---------------------------
| BBB b \ Barbara at LivingHistory stop co stop uk
| B B aa rrr b |
| BBB a a r bbb | Quidquid latine dictum sit,
| B B a a r b b | altum viditur.
| BBB aa a r bbb |
-----------------------------


On Tue,2007年10月9日05:15:49 +0000,gnuist006写道:
On Tue, 09 Oct 2007 05:15:49 +0000, gnuist006 wrote:

再次,我很沮丧,遇到一个全新的概念我听说
一直闻所未闻。它甚至不在保罗·格雷厄姆的书中,我在那里学习了一部分Lisp。它在Marc Feeley的视频中。


任何人都可以解释:


(1)其来源
Again I am depressed to encounter a fundamentally new concept that I
was all along unheard of. Its not even in paul graham''s book where i
learnt part of Lisp. Its in Marc Feeley''s video.

Can anyone explain:

(1) its origin



我认为其中一篇lambda论文。我不记得是哪一个。

One of the lambda papers, I think. I don''t remember which.


(2)它在emacs中的语法和语义lisp,常见的lisp,方案
(2) its syntax and semantics in emacs lisp, common lisp, scheme



elisp和Common Lisp没有它们(虽然sbcl和其他人可以在内部使用

continuation)。在方案中,CALL-WITH-CURRENT-CONTINUATION需要

a函数的一个参数,它绑定到当前的延续。

调用某个值的延续行为就像

CALL-WITH-CURRENT-CONTINUATION返回该值。所以

(来电/ cc(lambda(k)(k 42)))= 42

您可以将其视为转动调用后发生的事情/ cc

被调用到一个函数中。实现控制结构的延续最实用的用途,虽然还有一些其他巧妙的技巧

你可以玩它们。

elisp and Common Lisp don''t have them (although sbcl and maybe others user
continuations internally). In scheme CALL-WITH-CURRENT-CONTINUATION takes
a function of one argument, which is bound to the current continuation.
Calling the continuation on some value behaves like
CALL-WITH-CURRENT-CONTINUATION returning that value. So
(call/cc (lambda (k) (k 42))) =42
You can think of it as turning the whatever would happen after call/cc
was called into a function. The most practical use for continuations in
implementing control structures, though there are some other neat tricks
you can play with them.


(3)是否存在于python和java中?
(3) Is it present in python and java ?



当然不是Java,我不知道Python。我从来没有见过有人在Python中使用过他们的b $ b,但是pythonistas似乎想要添加一些东西,但是他们的语言只需要一个很好的lambda,所以我不会如果有人给b $ b加了一个电话/ cc,我会感到惊讶。 Ruby有它。

Certainly not Java, I dunno about Python. I''ve never seen someone use
them in Python, but the pythonistas seem to want to add everything but a
decent lambda to their language so I wouldn''t be surprised if someone had
added a call/cc. Ruby has it.


(4)它在汇编中的实现。例如,

指针从根本上来自间接寻址并且没有什么新东西。

那么你如何兼顾PC来做到这一点。
(4) Its implementation in assembly. for example in the manner that
pointer fundamentally arises from indirect addressing and nothing new.
So how do you juggle PC to do it.



你有小件Lisp。阅读Lisp in Small Pieces。

You have Lisp in Small Pieces. Read Lisp in Small Pieces.


(5)它如何与一个函数或子程序进行比较和优于

调用。它有什么不同。
(5) how does it compare to and superior to a function or subroutine
call. how does it differ.



你可以像函数调用一样使用它们。您也可以在C中使用它们,例如

setjmp / longjmp。您可以使用它们实现协同程序,或者

事件,或模拟非确定性或写出类似的东西((调用) / cc电话/ cc)

(电话/抄送电话/抄送))并让你的头爆炸,使用它像goto'的近亲

表兄弟或一般你可能想做的任何有害事情

你的程序中有控制流。

You use them like a function call. You can also use them like
setjmp/longjmp in C. You can implement coroutines with them, or
events, or simulate non-determinism or write things like ((call/cc call/cc)
(call/cc call/cc)) and make your head explode, use it like goto''s inbred
second cousin or in general whatever perverse things you might like to do
with the flow of control in your program.


>

非常感谢。


(6)任何可读的参考资料都能清楚地解释清楚吗?
>
Thanks a lot.

(6) any good readable references that explain it lucidly ?



Lisp in Small Pieces的实现细节,方案编程

语言例如。

Lisp in Small Pieces for implementation details, the Scheme Programming
Language for examples.

10月8日晚上10点59分,Barb Knox< s ... @ sig.belowwrote:
On Oct 8, 10:59 pm, Barb Knox <s...@sig.belowwrote:

>

Lambda演算。而不是函数A返回其调用者,

调用者提供了一个额外的参数(continuation),这是一个由A和A调用的函数B.的结果。在纯粹的延续

风格中编码,没有任何东西返回结果。


很容易将正常的函数式lambda

微积分机械转换为continuation-style,但事实并非如此。
>
Lambda calculus. Instead of function A returning to its caller, the
caller provides an additional argument (the "continuation") which is a
function B to be called by A with A''s result(s). In pure "continuation
style" coding, nothing ever "returns" a result.

It is easy to mechanically transform normal function-style lambda
calculus into continuation-style, but the reverse is not so.



请说明和参考

Explanation and reference please


>

你可以有一个spaghetti堆栈中的堆栈,或保持连续数据结构


>
You can have a "spaghetti stack", or keep continuation data-structures
in the heap.



图片,图表?一张图片胜过千言万语

A picture, diagram? a picture is worth a thousand words


这篇关于延续的基本概念的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆