lua-users home
lua-l archive

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


Philipp Janda wrote:
> I'm sure we all agree that a general table should be able to hold any
> string key including ones starting with _ + uppercase letter. However,
> a module table is not a general table, and there already has been Lua-Rio
> code in Lua 5.1 that used the `_M`, `_NAME`, and `_PACKAGE` fields in
> module tables, so the reservation of those names probably does not apply
> to global variables (and the registry) only.

But those tables and the tables that my module exports are by definition
distinct, aren't they? I'm worried that I'm missing something painfully
obvious, but I don't see how a clash could occur. A user of my module has
to require the module and save the table it returns, using an identifier.
That identifier holds one specific table and is distinct from any other
table from Lua-Rio or any other code.

More concretely:

	local split = require('split')
	if split._VERSION == 'whatever' then 
		whatever()
	else
		whatever_else()
	end

How can the _VERSION identifier in the one table ever clash with one in
another table?

-- 
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
    Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System