[Date Prev][Date Next][Thread Prev][Thread Next]
- 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
>> So I implemented something like this:
>> require 'canvas'
>> -- canvas usage
> To make it prettier, export a function
> function canvas.with(options)
> return canvas
> and use it as
> local canvas = require'canvas'.with'/dev/fb0'
> -- canvas usage