lua-users home
lua-l archive

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


I'm probably way too late to this discussion, or not completely
understanding what the conversations are about. However, I can offer
another datapoint about how Lua gets used in practice. I personally use
it both for private scripting, and as a game scripting tool (see
love2d.org).

Generally, I make use of some form of object oriented system, which I've
pulled out of PiL 2nd Ed. originally and have been evolving as my needs
have expanded. So, generally my code will look like this:

  Foo = class { x=1; y=2; }
  function Foo:init() self.z = self.x + self.y end
  Bar = Foo:subclass { x=3; }

  baz = Bar()

None of that is surprising, and I imagine is typical for most OOP style
lua users. To that end, my development style means that I've been always
putting my functions in a table (to use the colon syntactic sugar), so
that when I move classes into separate files, there's no need to use the
module function. The require function has been all I needed, and since
the filenames typically match the classnames, lazy-loading via a
metatable set on _G has removed the need to even work out my dependency
lists at the start of each file. I believe I learned that trick from Lua
Gems.

So, in terms of the heavy discussion that's going on here over the past
few days, I thought I could offer the insight that whatever replaces the
module function, I probably won't use that either.


William C. Bubel