lua-users home
lua-l archive

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


On Tuesday 04 October 2005 06:46, Diego Nehab wrote:
[...]
> Sorry, I was away and missed this nice thread. I feel guilty because I
> bothered Roberto some time ago with this change, so now it is my dutty
> to defend it. :)

I have to admit that I don't actually like this; I think it violates the 
Principle of Least Astonishment. I wouldn't *expect* the 'until' to be in the 
scope of the block inside, because (a) that's not how other Algol-ish 
languages do it, and (b) it's not visually part of the block.

However, to move on and actually answer the question:

[...]
>    local done
>    repeat
>     local l = io.read"*l" or "quit"
>     if l:match"^#" then continue end
>     local g, rest = l:match"(%S+)%s*(.*)"
>     done = handle[g](g, words(rest))
>    until done
>
> If you assume the old scoping rule and use the above declaration, you
> will still skip assignment to "done". Will Lua detect such a problem?
> Does this loop not work the same as the other? I might be just tired.

Execution will, however, pass through the 'local' statement that does an 
implicit assignment of nil (IIRC). Allowing jumps to the middle of a block 
(which continue would do using this scoping scheme) would bypass this. I 
don't believe that this is currently a problem, there would be issues with  
an optimising compiler that tried to reuse registers would have issues --- 
done would end up with an undefined value, depending on what had previously 
been in the register.

-- 
+- David Given --McQ-+ "It's the dawn of the day before the time of the
|  dg@cowlark.com    | land that the lost dinosaurs forgot to remember!"
| (dg@tao-group.com) | --- Ookla the Mok
+- www.cowlark.com --+ 

Attachment: pgpSQwpUXctdV.pgp
Description: PGP signature