lua-users home
lua-l archive

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


On Fri, Feb 17, 2012 at 12:30 AM, Jay Carlson <nop@nop.com> wrote:
> Between soar and Squish, "I want to ship a single .lua file" is no
> longer a reason to be cut&pasting code into your apps.

That's very cool. Yes, mea culpa, pl/init.lua is a devious piece of code.

For those unfamilar with the strategy, it does lazy loading of
modules.  This is to make life easier for lazy programmers:

require 'pl'
local d = arg[1] or error 'provide a directory'
if path.isfile (d) then
   for f in dir.dirtree(d) do
      print(f)
   end
end

require 'pl' does not actually bring in the whole 10K of the complete
library, but defines the subtables like 'path', 'dir', etc with a
custom __index. If you try to access a function in path it will do a
require 'pl.path' on demand.

Needless to say, this is a terrible thing to inflict on tool writers.

steve d.