Q: goto - continue problem

I am having difficulty understanding the goto semantics. Note the following for-loop:

    for i = SIG_ALERT, SIG_NONE_PENDING do
        if i % SIG_SLEEP == 0 or i % SIG_WAKEUP == 0 then
            goto continue
        end

        local signalName = thread:getSignalName( i )
        thread:sendSignal( test_h, i, signalName )
        utils:postMsg( sprintf("Sent %s to test thread.\n", signalName ) )

        ::continue::
    end

I trying to skip the SIG_SLEEP and SIG_WAKEUP iterations and my reading of the Lua manual suggests this should work. Alas it does not. When executed the for-loop generates the error, “Unexpected ‘goto’ near 'end”.

Any help would be very much appreciated.

for i = SIG_ALERT, SIG_NONE_PENDING do
        if i % SIG_SLEEP ~= 0 and i % SIG_WAKEUP ~= 0 then
	        local signalName = thread:getSignalName( i )
	        thread:sendSignal( test_h, i, signalName )
	        utils:postMsg( sprintf("Sent %s to test thread.\n", signalName ) )
        end
end

goto was added in Lua 5.2.

WoW’s Lua is based on 5.1.

/run print(_VERSION)
1 Like

I just found that in the formal documentation.

Thanks