Consider use_ok from the test system. Essentially, it should be

   require $module; $module.import; pass "load $module";

in its caller's context. But now that exportation is lexical, how can
use_ok be implemented? It must divert the symbols installed by &import
and have them installed in the caller site. Can that be done in pure
Perl? Even before that: can &import be written in pure Perl?

This obviously won't work:

   sub use_ok($module) {
       eval "package {caller.package}; require etc.";

because the installation work happens at the wrong lexical scope, and
because pads can't be changed at runtime.

More generally, how does one write friendly facades that mix in some of
the functionality of their real modules? (Eg., "IO" in Perl 5 that loads
many IO::* modules) I am not sure Role composition will always be strong
enough to do this. For example if a module one wishes to pull in isn't a
Role :)

There are over a hundred "use_ok" in the Pugs test suite; we are about
to work around the problem by changing them to use+pass, but that's
obviously the Wrong Thing. Is there a better workaround / a better
design we could use?


Reply via email to