Item1705: Ensure all uses of ListIterator have a 'use' or 'require'
Priority: Normal
Current State: Closed
Released In: 1.1.0
Target Release: minor
Not every call to listitterator had a require resulting in perl errors under certain circumstances. Btw. having a perl
require
in a busy loop might not be a good idea anyway.
--
MichaelDaum
Reopening per Olivier's notes from ML so it is not forgotten
QUOTE
Sorry, but we should have written some guidelines about that... We
discussed this quite extensively with CDot and Sven (maybe others too),
and I think the agreed conclusion was:
If you need a module, but don't need anything it imports, don't use
top-level require, but use:
use Module ();
So this should have been:
use Foswiki::ListIterator ();
I won't over-write your commit, but I think this rule makes sense.
If you don't see the difference, mainly, require is done at execution
time, whereas use is done as compilation time. So:
use Foswiki::ListIterator ();
is equivalent to:
BEGIN {
require Foswiki::ListIterator;
}
Without the (), it will call the import method of the module, which
might not be interesting, as most of the times it's only looking for a
function which doesn't exist, or doesn't do anything.
UNQUOTE
--
KennethLavrsen - 09 Jun 2009
Use
use
.
--
MichaelDaum - 10 Jun 2009