lua-users home
lua-l archive

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




On 18/08/15 06:08 PM, Rodrigo Azevedo wrote:

+1

How to define the "outer scope" ? (-1)

The block you put the do-end in is the outer scope. (Yes, you would have to use a do-end to be able to use export.)

-- outer scope
do
-- inner scope
export local v = 3
end

or

do
-- outer scope
do
-- inner scope
export local v = 3
end
-- outer scope again
end
Em 18/08/2015 16:43, "Soni L." <fakedme@gmail.com <mailto:fakedme@gmail.com>> escreveu:



    On 18/08/15 02:18 PM, Javier Guerra Giraldez wrote:

        On Tue, Aug 18, 2015 at 12:14 PM, Soni L. <fakedme@gmail.com
        <mailto:fakedme@gmail.com>> wrote:

            Can we get expressionblocks?

        AKA functions:

        local v = (local function() return 3 end)()



    Basically, but without the GC overhead of creating closures, or
    the VM overhead of calling functions.

    Alternatively:

    do
    <block>
    export local <namelist> = <explist>
    end

    Where `export` would create the locals on the outer scope. This is
    useful when creating closures without polluting the environment.

-- Disclaimer: these emails are public and can be accessed from
    <TODO: get a non-DHCP IP and put it here>. If you do not agree
    with this, DO NOT REPLY.



--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.