Closed britzl closed 9 years ago
It is valid and needed in some cases. Application may do not load all libraries to reduce time to init state. I work with such server it only loads basic and package library and register loaders to all other. So Lua programm should require all libraries (including string, math, io)
PS. You can read more in PIL chapter 30
Ok, thanks. I couldn't find chapter 30 though, there only seems to be 29: http://www.lua.org/pil/contents.html
But if it's recommended to require all libraries then why is LuaCov only requiring "debug"? And I have never seen the practice anywhere else either (penlight, busted etc). And I would argue that in the case of collecting code coverage it should be done as a separate task and in such a case reducing load time should not really be a concern.
Ok, thanks. I couldn't find chapter 30 though, there only seems to be 29.
It exists in second edition.
But if it's recommended to require all libraries then why is LuaCov only requiring "debug"? And I have never seen the practice anywhere else either.
Lua interpretator loads all libraries. Also many other application do that. So you do not need this.
But in some environment you have do this (I have VOIP server which create new Lua State for each phone session and it load only basic
and package
libraries). And if I want use e.g. penlight
library I have to load libraries by myself (or create PR to fix it).
So I requiring only "debug" because :
:)
Do you have a link to an online version of the second edition where I can read chapter 30? I was unable to find it.
I appreciate the extra explanation regarding why you require "debug" in your case. Still, I find it a bit odd that a shared and common library like LuaCov should contain code for a special case such as yours. In 99% of the use cases the require "debug" line makes no sense. Why not require the debug library in your own project immediately before the line where you require and start LuaCov?
Fork it, delete that line... LIVE! Be free! (That is the best part of Open Source after all)
I noticed a fairly recent change in runner.lua: https://github.com/keplerproject/luacov/commit/05c2d3455c3ce6fe45382589bedd91d433fb0672#diff-e6eeb062ec977cff33228290813a1ea3R12
What is the purpose of this require? Is it for some kind of backward compatibility? I wasn't even aware that it was valid Lua to require the "builtin" modules, such as debug, math etc