lua-users home
lua-l archive

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


It was thus said that the Great Josh Simmons once stated:
> On Sat, Oct 22, 2011 at 2:07 PM, Sean Conner <sean@conman.org> wrote:
> > It was thus said that the Great Josh Simmons once stated:
> >> On Sat, Oct 22, 2011 at 10:07 AM, Sam Roberts <vieuxtech@gmail.com> wrote:
> >> > On Fri, Oct 21, 2011 at 3:59 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
> >> >
> >> > I just don't want to rewrite everything for dubious advantage.
> >> >
> >> You say rewrite but you mean s/^function /function M./c
> >
> >  And then go back and fix every instance of "local function M." beacuse
> > that causes a syntax error.
> >
> >  And don't forget variables that might be part of a module.  For instance,
> > at work, I have a module that is nothing but values.  Yeah, I could go back
> > and change each line but still, I'm not a fan of manually placing stuff into
> > the module table.
> >
> >  -spc (I'm not happy with the global spamming of module, but the rest of it
> >        I like ...)
> >
> 
> You missed the anchor at the start of that regex, and yes values need
> another find/replace which altogether should take about 5 minutes and
> result in a module that works in lua 5.1, 5.2 and luajit.

  Yes, I did miss the anchor, but I have a module where a function isn't
defined at column 1, so the regex above would miss that [1].  Granted,
testing should have shown the error, but it's not the five-minute fix you
think it is.

  -spc (Learned the hard way that hardly anything dealing with computers is
	a "five-minute" fix)

[1]	The code is literally:

	------[ begin ]--------
	module("picture")

	if pcall(require,"gd") then
		function generate(picid,person)
		  ...
		  -- code using gd to draw stuff
		  ...
		end
	else
		function generate(picid,person)
		end
	end
	-----[ end ]----------------

	This is just a small part of our testing tool; pictures are nice to
	have, but aren't always required.  So, for the systems were GD isn't
	installed [2], we can still include this module and not have it fail
	on us.

[2]	Primarily Solaris systems.  I'm in QA, not ops, so I don't have
	access to arbitarily install packages, even assuming I knew how
	Solaris does packages.  Heck, half the time the Solaris systems
	don't even have a development system and I need to copy executables
	around [3].

[3]	I even created a special Lua interpreter to include *all* the
	modules we use into a single executable (about 3M in size) just
	because I can't be guarenteed everything I need to run Lua would be
	installed.  It was a fun exercise in not only including the C-based
	modules, but the Lua-based modules as well.