关于 OnLisp 中的延续
regarding continuation in OnLisp
我对已经回答的问题仍然感兴趣。
continuation in common lisp by macros — regarding an implemetation in OnLisp
如果 Paul Graham 的假设是正确的,尤其是当从 (A 5) 变为 (B 1) 时,会发生什么情况? cont 绑定到这里的是什么?
当文字说
时,还有一个困惑
=bind, is intended to be used in the same way as multiple-value-bind. It takes a list of parameters, an expression, and a body of code: the parameters are bound to the values returned by the expression, and the code body is evaluated with those bindings.
我无法直接从 =bind 的宏定义中看到绑定,它看起来像
(defmacro =bind (parms expr &body body)
`(let ((*cont* #'(lambda ,parms ,@body))) ,expr))
是否仅当 =values 稍后出现时才会发生绑定?
宏将延续 *cont*
设置为将所有变量作为参数的 lambda,然后计算表达式 expr
。表达式应使用其最终值调用延续,这可以通过调用 =values
函数间接完成,或直接使用 funcall
完成。与使用任何表达式的 return 值隐式调用延续的 Scheme 不同,您必须通过调用 *cont*
或使用 =values
而不是 return从任何函数中调用。
我对已经回答的问题仍然感兴趣。
continuation in common lisp by macros — regarding an implemetation in OnLisp
如果 Paul Graham 的假设是正确的,尤其是当从 (A 5) 变为 (B 1) 时,会发生什么情况? cont 绑定到这里的是什么?
当文字说
时,还有一个困惑=bind, is intended to be used in the same way as multiple-value-bind. It takes a list of parameters, an expression, and a body of code: the parameters are bound to the values returned by the expression, and the code body is evaluated with those bindings.
我无法直接从 =bind 的宏定义中看到绑定,它看起来像
(defmacro =bind (parms expr &body body)
`(let ((*cont* #'(lambda ,parms ,@body))) ,expr))
是否仅当 =values 稍后出现时才会发生绑定?
宏将延续 *cont*
设置为将所有变量作为参数的 lambda,然后计算表达式 expr
。表达式应使用其最终值调用延续,这可以通过调用 =values
函数间接完成,或直接使用 funcall
完成。与使用任何表达式的 return 值隐式调用延续的 Scheme 不同,您必须通过调用 *cont*
或使用 =values
而不是 return从任何函数中调用。