lua-users home
lua-l archive

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


on 2/5/07 8:26 AM, Rici Lake at lua@ricilake.net wrote:

> The complex part of implementing smalltalk blocks is the correct
> handling of ^ (return) inside a block. This could be macro-expanded
> into call/cc, if you have call/cc (actually, only a very limited form
> of call/cc is necessary), but I don't see any obvious way of doing
> that in Lua without introducing a coroutine; furthermore, the
> coroutine solution may fail unexpectedly because Lua coroutines
> lack delimiters.

A useful bit of subtlety to be aware of.

Fundamentally, blocks are a great way to enable non-guru programmers to
implement control structure like entities, but without support for non-local
return (or break for that matter), they won't really feel quite like control
constructs and adding such support potentially leads to continue capture
issues though those can be addressed by declaring that a function scope
closes the first time we exit from the function.

Mark