lua-users home
lua-l archive

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


Hakki Dogusan wrote:
> - lcario creates two -namespace- tables:
>        cairo - for functions
>        CAIRO - for constants, enums
> 
>     this simplifies translating C code to Lua, ie:
>        cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
>     becomes:
>        cairo.set_operator (cr, CAIRO.OPERATOR_ADD)

Users can achieve the same result pretty easily:

local cairo = require 'lcario'
local CAIRO = cairo

and then the same code ported from C:

cairo.set_operator (cr, CAIRO.OPERATOR_ADD)

That way you don't have to pollute the global namespace with several
symbols (you could even have no global symbol and only use require
return value). You can also put all constants in a sub-table to more
clearly distinguish them:

local cairo = require 'lcario'
local CAIRO = cairo.constants