[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: NCLua canvas module implementation: Silly question
- From: Sam Roberts <vieuxtech@...>
- Date: Mon, 16 Jan 2012 12:04:38 -0800
2012/1/16 Ezequiel García <elezegarcia@gmail.com>:
> 2012/1/16, Francisco Sant'anna <francisco.santanna@gmail.com>:
>> If I got it right, I think you can also change the Canvas initialization:
>>
>> -- local Canvas = {}
>> local Canvas = _M
>
> Why? (with a head scratching picture)
You are trying to mix two ways of making a module. One is to just
return at the end whatever the module should be (a new canvas), the
other is to use the module() function. Its confusing, and doesn't
work.
module() creates a table to be your "module", makes it the environment
(so any "global" definitions go into it magically), and also arranges
for _M to be defined as that table so you can access it.
I don't think you should be calling module(), but you might be able to
make _M "be" the base canvas, and not return anything.