News for hackers. Stuff that matters.
Re:Using {Blocks} in Rust and Go for Fun and Profit by Anaminus on Wednesday January 25, 2023 @09:55AM (#34518957)
This is a thing in Lua as well, with do-end blocks:

    local foo
    do
        local bar = 42
        -- Same as `foo = function() ... end`, so this sets the local foo variable.
        function foo()
            return bar
        end
    end
Because Lua has no significant whitespace, it can be made to look like some kind of specific syntax:

    local foo do
        local bar = 42
        function foo()
            return bar
        end
    end
Though I think this is too clever, so I like to insert a semi-colon to make it clear what is happening:

    local foo; do
        local bar = 42
        function foo()
            return bar
        end
    end

There are no comments on this comment yet.