lua-users home
lua-l archive

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


On 7/25/05, Matthew Percival <matthew@capgo.com> wrote:
>         I assume chunk contains the contents of my .lua file now: do I use this
> in some way, or should I change it to `if chunk then dofile()'?  I think
> I may make a simple function for this, so I can call it often: I can
> definitely see myself using something like this a lot!

"chunk" is a lua function containing the code in the file, so just
execute it. In fact, you can rewrite dofile in terms of loadfile as
follows (minus the differing error semantics, and return value
semantics):

function dofile(file)
    local thechunk = loadfile(file)
    thechunk()
end

Ben