lua-users home
lua-l archive

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

On Feb 18, 2013, at 8:26 PM, Andrew Starks <> wrote:

> On Mon, Feb 18, 2013 at 11:46 AM, Gavin Kistner <> wrote:
>> Put more simply: how would you rewrite the following suite of files so that
>> the user can "require 'master'" and not spam the global namespace with
>> "MASTER", but still have all the assertions pass?
> Having read the thread after I gave my answer, sigh.... I like Petite
> Abeille's answer the most, although it requires a rewrite of
> everything I"ve done.

Thank you very much for your contributions. I'd be interested in your response to my current solution as described here:

> MASTER = require 'simple'(MASTER)  --you MADE ME DO THIS!! Yuck.

LOL...and yes, yuck. :) Modifying each sub-file to be a function seems rather beastly, but it certainly does cleanly allow the shared master table to be passed around.

> It's one of those compact examples that was carefully crafted to cover
> every use case and, as a result, left me angry when I was done solving
> it. I now need to shower, although I mean no disrespect to your
> illustrating example.


> That is to say, if you think my solution looks worse than yours,
> consider that your example is purpose-conceived to be difficult, not
> useful in real life. In real life, doing these kinds of things is just
> bad design, although one or two in of each in a single project is
> certainly possible.

For what it's worth, it is decidedly compact, but it does actually exactly cover the specific problems I faced with my then-current implementation for my project. It was truly real-world.

I am not averse to the suggestion that perhaps the way in which I broke up the files was bad design, though I'm not seeing specifics of where I've made things too tightly coupled or such. If you like, you're welcome to browse the pre-local implementation here:

Thanks again for your feedback.