lua-users home
lua-l archive

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


I used it in a loop to skip to the next element in several places in my 5.2 project:
 
    for filename in keys( all_filenames ) do
        if file_failed_to_open[filename] then
            goto nextfile
        end
        -- Open a file
        local output_filename = get_output_filename( filename )
        local file_writer = codewriter.create( output_filename )
 
        -- failure? go to the next file
        if not file_writer then
            goto nextfile
        end

        -- Do stuff with the file here ...

        ::nextfile::
    end

I also used it here for the same purpose, and also to repeat this loop again if necessary. When a new noun is added, it basically needs to be done again. This probably isn't the most efficient way of doing things, but hey, optimize later, right?
    -- Now, go through every verb and find out if it should be included based on the nouns obtained
    -- for each verb,
    local potentially_used_verbs = {}
    ::check_all_verbs::
    for index, verb in verbs.file_pairs( filename ) do
        -- Go to the next if this verb's already been added, no need to check it again
        if potentially_used_verbs[verb] then goto next_verb end

        -- (code here to "goto next_verb" if the verb had an input parameter that wasn't in the nouns list.)
 
        -- (code here to set the "new noun added" flag if a new noun was detected in the current verb)
 
        if new_noun_added then
            goto check_all_verbs
        end
        ::next_verb::
    end