lua-users home
lua-l archive

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


I'm implementing a module-supporting "strict" system, along the lines of
strict.lua. The code so far looks good though there's a small, almost
cosmetic problem. The error messages printed (from Roberto's code) are:

	error("assign to undeclared variable '"..n.."'", 2)

and

	error("variable '"..n.."' is not declared", 2)

with n being the name of the culprit.

However, if the error occurs in connection with a module (if, for
example, someone refers to a non-existent function or variable in a
module), the message doesn't show the name of the module. For all
user-defined modules this is in module._NAME, so I can easily retrieve
and print it.

Alas, the tables for the standard library (the "pseudo modules" like os,
string etc.) do not come with a _NAME field. (There's also no _M and
_PACKAGE.) It would be nice (read: consistent:-)) if the standard
modules could be made to behave, as far as possible, like user-defined
modules. (There are perhaps other areas with other small differences
which I, being new to Lua, have not yet explored.)

For the time being I have q&d-patched these fields into my code, but if
there's no specific reason against, could this be added in a future Lua
release?

-- 
cheers  thomasl

web : http://thomaslauer.com/start