lua-users home
lua-l archive

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

That's interesting. Is was wondering too. When to use a module (require) and when to use dofile...

Have a nice day,

Op 6 jul. 2012 14:24 schreef "Peng Zhicheng" <> het volgende:
于 2012-7-6 14:50, steve donovan 写道:

The short answer: require() is like dofile(), in that the source is
separately compiled, but it looks up the source on the _module path_.

steve d.

and what's more, `require' will load a chunk only once:

the first time you `require' some module, it load the chunk,
and caches the result (or simply a `true' if no result)

all subsequent call to `require' will return the cached value.