lua-users home
lua-l archive

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


Quoth Jerome Vuarand <jerome.vuarand@gmail.com>, on 2012-11-10 03:51:19 +0000:
> Here I disagree with Drake Wilson. I think it's easier to directly
> call your c_loader function:
> 
>     package.preload[k:lower()] = c_loader(k:upper())
>     package.preload[k:upper()] = package.preload[k:lower()]

I respect your opinion, but I think this is not a good idea because it
means that all scripts enumerated are immediately loaded into the Lua
heap as chunk functions even if they are not executed yet.  That is
why the c_loader call should be deferred until the preload function is
actually called.  (Renaming the c_loader function to something like
load_script makes this easier to see.  "preload" is actually kind of
an unfortnuate name, now that I think of it.)

Of course if it is _desirable_ to have everything in the heap at
startup time instead, then the above is inverted.  :-)

   ---> Drake Wilson