简体   繁体   中英

regarding continuation in OnLisp

I am still interested in the question which has been answered.

continuation in common lisp by macros — regarding an implemetation in OnLisp

What will happen if Paul Graham's assumption is correct especially when change from (A 5) to (B 1)? What is cont bound to here?

And one more confusion when the text says

=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.

I cannot see the binding directly from the macro definition of =bind which looks like

 (defmacro =bind (parms expr &body body)
  `(let ((*cont* #'(lambda ,parms ,@body))) ,expr))

Does the binding happens only when =values comes in later?

The macro sets the continuation, *cont* , to be a lambda which takes all of your variables as arguments, and then evaluates the expression expr . The expression is expected to call the continuation with its final value, which can be done indirectly by calling the =values function, or directly with funcall . Unlike Scheme, where the continuation is implicitly called with the return value of any expression, you must explicitly write your code in continuation-passing style by calling *cont* or using =values instead of returning from any function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM