|
On 2-Nov-06, at 9:39 PM, Glenn Maynard wrote:
This isn't mentioned in 5 - Standard Libraries. Also, these functionsdon't actually use it; that is, if I luaopen_table() with a parameter of "tab", the table library is still loaded into "table", so passing "table"along here is a bit confusing.
That's true.Also, I forgot to mention that I believe that io is the only library which uses the function environment feature (of the standard libraries, that is; third-party libraries may well use it.)
As I understand it, the purpose of passing the module name is not so that the library will create a global with that name; it is to tell the library what the name is in case it needs to know. None of the standard libraries do, but one can imagine uses for this feature (for example, locating related libraries).
I'm personally of the opinion that libraries should not create globals; they should return objects and let the caller put them where they like. Of course, the standalone interpreter would put the standard library in standard globals, but I think it ought to be the customer of the library and the library itself which makes that decision. The library is (or should be) registered with the package system with its full name (which could be dotted); that's the name which it needs to be given, in case it cares. (Just my S/0.02 worth, doesn't correspond with anyone else's prejudices.)