lua-users home
lua-l archive

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


On Tue, Oct 18, 2011 at 3:16 PM, Patrick Mc(avery
<patrick@spellingbeewinnars.org> wrote:
> I could then write code in another file that would patch the two together
> something like this:
>  function sillyCode()
> include("functions.lua)
> silly1()
> local y =2
> include("locals.lua")
> print(x + y)
> end

Ah, you want something that works like C's #include - that is, _just
pulls code into the current file_.

I see sometimes a need for it, e.g. if you have a lot of local aliases
for global functions, but the Lua way here is to _separately compile_
each file brought in with dofile() or require().

Generally, history has not been kind to plain include - it's the major
boneheaded thing about C (hi, Petite!) which came to its full horrible
fruition with C++.  The poor compiler (after all) still has to process
all this included stuff to compile the file, so the C++ compiler goes
through multiple 10KLocs of source to compile a modern "hello word' .

steve d.