lua-users home
lua-l archive

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


G'Day,

> 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

	Thanks for the clarification: this is exactly what I needed.  Well, if
anything, it is a tad easier than I was expecting!  I will put together
a functions similar to this and play around with it a bit: it should
prove awfully useful.

	-- Matthew