lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Jul 19, 2023 at 06:24:59AM +0200, bil til wrote:
> Am Di., 18. Juli 2023 um 16:16 Uhr schrieb Marcus Mason <m4gicks@gmail.com>:
> > local B = coroutine.clone(A)  -- hypothetical
> >
> 
> ... and for which application do you think of this? Can you describe
> your application more in detail?

The common term for this is call/cc or call-with-current-continuation:
https://en.wikipedia.org/wiki/Call-with-current-continuation

IIRC, formally the call/cc primitive can be used to implement most (all?)
forms of control flow, including common controls like return or less common
like backtracking, which is what Marcus Mason seems to have had in mind and
which is extremely convenient for implementing parsers or when debugging.

Another term is multi-shot continuations, as opposed to Lua's one-shot
continuations. The difference is described by Ana Lucia de Moura and Roberto
Ierusalimschy in their paper Revisiting Coroutines (2004); specifically in
section 4.2 One-shot Continuations:
http://www.inf.puc-rio.br/~roberto/docs/MCC15-04.pdf