[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] vstruct - 1.0 beta 2
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Sat, 26 Jul 2008 13:31:45 +0200
2008/7/25 Ben Kelly <ranavin@gmail.com>:
>> The tricky module-mechanism is not easy to
>> understand. I mean things like this
>>
>> local name = (...):gsub('%.[^%.]+$', '')
>> local read = require (name..".read")
>>
>> and similar lines.
>
> I'm not actually entirely happy with that; it feels ugly and slightly
> hackish. I have yet to come up with a better way, though.
The standard 'module' function does that work. You can replace:
local name = (...):gsub('%.[^%.]+$', '')
local read = require (name..".read")
local write = require (name..".write")
local compile = {}
with:
module(..., package.seeall)
local read = require (_PACKAGE.."read")
local write = require (_PACKAGE.."write")
local compile = _M