[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: upcoming changes in Lua 5.2 [was Re: Location of a package]
- From: Renato Maia <maia@...>
- Date: Thu, 28 Feb 2008 14:34:39 -0300
On 28 Feb 2008, at 13:35, Mark Hamburg wrote:
Nothing. But sometimes one wants more logic which gets in the way
of the if.
For example:
while true do repeat
if processing_suspended() then
wait_until_processing_not_suspended()
break -- continue
end
local item = queue:peekFront()
if not item then
wait_queue_non_empty()
break -- continue
end
if item:onlyOnTuesdays() then
wait_until_Tuesday()
break -- continue
end
-- Now it's okay to go process the item
queue:popFront()
-- Process
I don't want to be annoying, but you could also write it as:
while true do
if processing_suspended() then
wait_until_processing_not_suspended()
else
local item = queue:peekFront()
if not item then
wait_queue_non_empty()
elseif item:onlyOnTuesdays() then
wait_until_Tuesday()
else
-- Now it's okay to go process the item
queue:popFront()
-- Process
end
end
end
--
Renato Maia
PhD student at PUC-Rio
__________________________
http://www.inf.puc-rio.br/~maia/