--- Sébastien Aperghis-Tramoni <[EMAIL PROTECTED]> wrote:

> Eric Wilhelm wrote:
> >>      use relative;
> >>      my $Customer = import relative qw(Report Customer);
> >
> > This changes the require() on Foo::Report and Foo::Customer to run-
> > time though, right?
> 
> Right, but I'd say that for writing object-oriented code, there isn't
> such a need to do things at compile time, is it?

You know, I hadn't considered the runtime/compile-time issue when I
first saw this.  Eric's right that this does change the semantics.  I
suppose one could wrap it in a BEGIN block, but that makes it worse:

  use relative;
  my ( $Report, $Customer );
  BEGIN {
      ( $Report, $Customer ) = import relative qw(Report Customer);
  }

I do get tired of writing code like that (it happens a lot in test
suites when I have "use_ok $CLASS" in a BEGIN block).

I do agree that with OO modules that compile-time should be less of an
issue, but it's not universally the case.  Still, I think the "import
relative" is probably enough for me.

Cheers,
Ovid

--
Buy the book  - http://www.oreilly.com/catalog/perlhks/
Perl and CGI  - http://users.easystreet.com/ovid/cgi_course/
Personal blog - http://publius-ovidius.livejournal.com/
Tech blog     - http://use.perl.org/~Ovid/journal/

Reply via email to