lua-users home
lua-l archive

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


Peter Hill:
> It's probably all for the good to keep the Return & Break limitations
> consistent with each other even if it's not actually needed syntactically.

RLake@oxfam.org.uk:
> This has always puzzled me. Under what circumstances would you want to put
> a statement after return or break? It could not possibly be executed, and
> I'm quite happy to have the syntax checker tell me that.

To comment out following statements (yuk!). In Lua5 we can now just
use --[[...]] which is a whole lot clearer :-).


While on the topic of Return/Break syntax... since it is a syntactic limit
it should be included in the syntax diagram (not buried in the manual).
Manual writers take note! So, we might have:

    <chunk> ::= {<state> [';']} [('return' [<explist1>] | 'break') [';']]

with <state> now no longer including "return" or "break" statements.


RLake@oxfam.org.uk:
> While we're dreaming, I'll put in my plug again for non-local exits,
> Dylan-style, instead of break labels and exceptions. The idea is very
> simple:

Ok, I couldn't follow this "very simple" idea :-(. Could you give me a
layman's version?

> begin name chunk end
>
> is an expression (not a statement) in which "name" is locally defined as a
> first-class continuation with the restriction that it cannot be used after
> the begin block is exited.

What is a "first class continuation"?

> However, it can be passed as an argument. That is, name is defined as a
> function with a variable number of arguments; calling it causes the begin
> block to evaluate to those arguments.

Ah, I think I see! It's like a "return" statement but each instance is bound
(using some sort of closure) to the upper block it was created in! Ie, it is
a sort of set-jump / long-jump thing (well, more of a long-return, I
suppose). Is that right?

*cheers*
Peter Hill.