[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: break operator
- From: Eike Decker <zet23t@...>
- Date: Tue, 11 Aug 2009 12:45:00 +0200
Hi,
I recently had a loop where I had to read a value that looped like this:
while true do
local line = readline()
if not line then break end
...
end
I know that there are ways how to write this in a nicer way (i.e.
having an iterator function), but wouldn't it be more nice if this
would work as well this way:
while true do
local line = readline() or break
...
end
I think it would break some relationship to have a language feature
like that - however it simply looks so much nicer... Of course this
concept could be used in a coroutine environment, i.e. having a "stop"
function that yields the coroutine, i.e.
while true do
local line = readline() or stop()
...
end
which looks already quite nice...
cheers,
Eike