[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Re[2]: why no "continue" statement for loops?
- From: "Bilyk, Alex" <ABilyk@...>
- Date: Mon, 23 Jun 2003 16:19:09 -0700
-----Original Message-----
From: Nick Trout [mailto:nick@rockstarvancouver.com]
Sent: Monday, June 23, 2003 4:04 PM
To: Lua list
Subject: RE: Re[2]: why no "continue" statement for loops?
> Adding 'continue' would be sort-of "beautiful" since it would make the
> language orthogonal (is that the right word - meaning having the full
> of something, instead of just half of it).
Adding continue would be nice. It is pretty useful and the patch looked
very small.
> I'm sceptical about break N as well (for the same reasons).
Just out of interest, what happens in the following example?
function foo()
local foo2 = function()
while true do
break 2
end
end
while true do
foo2()
end
end
Does the "break 2" exit foo()? Or just foo2()?
I would expect an error to be generated by this code. 'break N' should not be expected to cross call frame boundary for a simple reason that the context of a function call is generally unknown. That is, a person writing a function (foo2 in the above snippet) can make no assumption who and under what circumstances may call this function during the life time of its source code. Thus, enabling 'break N' to cross call boundaries would be no more than a case of trickery in my view.
I don't really like the idea of "break N", but then I haven't really
used a language that uses it. Using "return" and nested functions
somehow seems cleaner, but if it's optional it might be useful
occasionally.
--nick
Alex