develooper Front page | perl.perl6.language | Postings from July 2005

What do use and require evaluate to?

Thread Next
From:
Ingo Blechschmidt
Date:
July 12, 2005 05:16
Subject:
What do use and require evaluate to?
Message ID:
loom.20050712T135351-21@post.gmane.org
Hi,   
   
what do use and require evaluate to?  
  
S06 suggests it's probably some kind of Module object:   
  The result of a use statement is a (compile-time) object that also has   
  an .assuming method, allowing the user to bind parameters in all the   
  module's subroutines/methods/etc. simultaneously:   
     
      (use IO::Logging).assuming(logfile => ".log")   
   
We could make (use Foo) evaluate to the class object Foo,   
allowing:   
   
    my $foo = (use Foo).new(...);   
   
Alternatively, we could go the Perl 5 way and return the   
last thing evaluated in Foo.pm (which might be a Module   
object, assuming that module Foo {...} evaluates to Foo).   
   
   
What do successive uses of use and require evaluate to?   
Perl 5 is inconsistent:   
   
    $ cat > Foo.pm   
    package Foo; 42;   
    $ perl -we 'warn require Foo; warn require Foo'   
    42 at -e line 1.   
    1 at -e line 1.   
   
I'd like Perl 6's use and require to return the same thing.   
   
   
In Perl 5, %INC maps the partial path names of the modules   
loaded to their absolute ones. What should the keys and values   
of %*INC be in Perl 6?   
   
   
--Ingo   
   
--    
Linux, the choice of a GNU | self-reference, n. - See self-reference     
generation on a dual AMD   |    
Athlon!                    |    


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About