lua-users home
lua-l archive

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


David Kastrup <dak@gnu.org> writes:

> "Joseph Manning" <manning@cs.ucc.ie> writes:
>
>> On 2011-Jun-15 (Wed) at 00:59 (-0400), phlnc8 wrote:
>>
>>>> On Mon, Jun 13, 2011 at 4:27 PM, Alexandre Erwin Ittner
>>>> <alexandre@ittner.com.br> wrote:
>>>> ...
>>>> > A "label" keyword would be great too
>>>>
>>>>  I like this idea of a "label" reserved word.
>>
>> +1
>
> There has been some notion of making coroutines callable like
> subroutines, more or less making coroutine.wrap a one-shot operation for
> setting up a coroutine.  It would be nice if labels were callable in a
> similar way.  However, a function or coroutine can be put into a
> variable, calling the variable later, and that does not appear to work
> reasonably well for forward jumps.  One could possibly work with forward
> declarations:
>
> xxx = label zzz
> [...]
> xxx() -- jumps forward
> [...]
> (label zzz)() -- jumps forward
> [...]
> label zzz
> [...]
> zzz() -- jumps backwards

Here is another idea: use a keyword "entry" that works just like
"function".  The difference is that when you fall through to the end of
an entry block (possibly also when you issue return), you end in the
enclosing scope after the entry end rather than at the "caller".

Unfortunately, I have no clear idea how to do forward jumps this way.

-- 
David Kastrup