By loader do you mean the code that called eval require ... or Perl itself? If you mean Perl I would agree though I'm not sure how it would do it. As you say, loading isn't transactional. The partially compiled code may have successful BEGIN blocks that placed symbols in any number of namespaces, GLOBAL::CORE among them.
If by "loader" you mean the code that called eval require ..., then the problems are even greater as regards clean-up. To begin with, the caller doesn't have the kind of knowledge that the compiler does about how much was actually compiled. The compiler could keep track of all symbols it has created/modified along with their pre-load values and restore them. This isn't really something the calling code could do.
As for "doesn't make sense to continue"... that depends, at least from the caller's point of view. Indeed, it does not make sense to continue to do anything that uses the module's functionality - it is broken. However, if the module is an optional plug-in, then the brokenness may simply mean that one menu item is omitted or one item in a for-loop gets skipped with next.
There is a second issue with removing the module name from %INC: as it stands now, having the module name placed in %INC has one valuable side effect. It makes it possible to tell the difference between a call to require that fails because the module doesn't exist at all and a require that fails because the module is broken. The missing module doesn't add anything to %INC and the failed one does. That can be useful when testing - we probably don't care if a require fails because an optional module is missing. In that case we want to skip any related tests. We probably do care if a require fails because an optional module is broken. In that case we want at least one failed test for the broken compilation plus several others marked as either fail or TODO.
Without that distinction one would need to parse the exception itself - not terribly reliable when locales are taken into account. However, as discussed in the original post, that only happens on the first call to require. There after the broken and successful module both look like they succeeded.
Best, beth
In reply to Re^2: Detecting broken modules
by ELISHEVA
in thread Detecting broken modules
by ELISHEVA
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |