lua-users home
lua-l archive

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


	Hi

	Some hours ago I replyed Bernd about his problems with Compat-5.1
and Diego warned me (in private) about some mistakes.  I'll try to correct
what I said.

Yes I know, LUA_INIT has it already but I try to figure out why some of
our lua libraries which are required twice (because of dofile) actually
work the first time round but fail the second time round (even if
_LOADED says it is loaded already).

Am I just missing something here??
	The bug is that compat-5.1.lua should register itself, like:

package.loaded["compat-5.1"] = true
	This was my first mistake: this is not a Compat's bug.
The actual implementation is correct and the above "patch" would
NOT be recommended.  The fact is that Compat is NOT a library that
should be "required".

	Sorry about that.  You could add that line somewhere in the
file.  You could check for _COMPAT51 global variable, which is defined
by the file, and decide if you have to require it or not.
	The recommendation have to be rewritten.
	Compat is just a way to achieve Lua 5.1 behavior with Lua 5.0.
Therefore, it is not a library; it is more like a "patch", or another
Lua version (something like a 5.1/2).
	A library should not depend on Compat in the sense that it should
be required, as it should not try to require some specific Lua version.
	An application have to load Compat before anything else to assure
that everything would work correctly.  This "correct work" involves the
redefinition of the function require, so it is strange to use require
to load Compat.
	Back to the original problem, Bernd, I think your libraries
should be loaded with require (instead of dofile) to avoid useless
repeated loads; moreover, only the application should load Compat at
the very beginning.

	I hope I am clear now,
		Tomas