[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to properly initialize a module?
- From: Tim Caswell <tim@...>
- Date: Tue, 6 Dec 2011 12:26:42 -0600
I think stock lua's require allows this and I know I do in Luvit, but
often I'll make the module itself be a function instead of a table.
Then it would be
local Canvas = require('canvas')
local canvas = Canvas('/dev/fb0')
On Tue, Dec 6, 2011 at 12:11 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> So I implemented something like this:
>>
>> require 'canvas'
>> canvas.init('/dev/fb0')
>> -- canvas usage
>
> To make it prettier, export a function
>
> function canvas.with(options)
> canvas.init(options)
> return canvas
> end
>
> and use it as
>
> local canvas = require'canvas'.with'/dev/fb0'
> -- canvas usage
>