lua-users home
lua-l archive

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


--- El mar 6-dic-11, Petite Abeille <petite.abeille@gmail.com> escribió:
> You can also make a table callable (see metamethod
> __call).
> 
> In that case, require returns a callable table, to which
> you can pass a parameter, which don't need to be parenthesis
> if it's a string or table.
> 
> Therefore:
> 
> local myFoo = require 'foo' 'bar'
> 

So, in other words, to achieve this from C-side:

1. I must create a table.
2. Assign it a metatable with the __call metamethod.
3. This __call method will perform the module init.

But, what if I don't pass any parameter to require? 
Will it call metamethod __call ?

I want to be able to do both:

  require 'canvas' -- assumes, '/dev/fb0'

and,

  require 'canvas' '/dev/fb1' -- changes, default behavior

Thanks,
Ezequiel.