Re: RFC 253 (v1) UNIVERSAL::require()

2000-09-18 Thread John Porter

 As a solution, a UNIVERSAL:::require() method can be added with the following
 syntax:
 
 $module = "Some::Module";
 $module-require;

Seems to me that it would need to be written as

$module-UNIVERSAL::require;

How do you propose to avoid that?



 What should happen if UNIVERSAL::require() is called as an object method? 
 Should it Ceval "require ".ref $obj or should it be an error?  Because the
 situation is very rare when you will have an object from a class which has not
 yet been required, UNIVERSAL::require() should only work as a class method. 
 C$obj-require should be an explicit run-time error.

No.  Any reason not to let the error arising from Ceval "require ".ref $obj
to do its normal thing?

The case may be rare, but it should be allowed: UNIVERSAL::require() should
DTRT given an object ref.

-- 
John Porter

We're building the house of the future together.




Re: RFC 253 (v1) UNIVERSAL::require()

2000-09-18 Thread Nathan Wiger

John Porter wrote:
 
  As a solution, a UNIVERSAL:::require() method can be added with the following
  syntax:
 
  $module = "Some::Module";
  $module-require;
 
 Seems to me that it would need to be written as
 
 $module-UNIVERSAL::require;
 
 How do you propose to avoid that?

Huh? All classes inherit from UNIVERSAL implicitly. It's the same reason
you can write:

   $module-can('dance');

For any class, even one that doesn't exist.

-Nate



Re: RFC 253 (v1) UNIVERSAL::require()

2000-09-18 Thread John Porter

Nathan Wiger wrote:
 
 Huh? All classes inherit from UNIVERSAL implicitly.

Yes, but at that point in the execution, $module is not a class.


 It's the same reason you can write:
 
$module-can('dance');

Once upon a time this was not possible.  I guess it has changed.

-- 
John Porter

We're building the house of the future together.




Re: RFC 253 (v1) UNIVERSAL::require()

2000-09-18 Thread Michael G Schwern

On Mon, Sep 18, 2000 at 11:20:15AM -0400, John Porter wrote:
 Seems to me that it would need to be written as
 
   $module-UNIVERSAL::require;
 
 How do you propose to avoid that?

What is a class but a package?  And what is the name of a class but a
package name?  And since there's no concept of an undefined package,
any valid package name is a valid class (I'm sure there are exceptions).

It all works.  Run the prototype code on any module.


 No.  Any reason not to let the error arising from Ceval "require ".ref $obj
 to do its normal thing?
 
 The case may be rare, but it should be allowed: UNIVERSAL::require() should
 DTRT given an object ref.

The case is so rare for one having an object *before* loading its
class that most of the time C$obj-require will be a programming
mistake.  If C$obj-require is made to work, the mistake will become
silent and not be noticed until much futher on down in the code.  

Garbage In, Error Out.

If you really want it, the wrapper require() is trivial.


DTRT?  Data Terminal Ready, Tim?  Document Filing and Retrieval Tedium?

-- 

Michael G Schwern  http://www.pobox.com/~schwern/  [EMAIL PROTECTED]
Just Another Stupid Consultant  Perl6 Kwalitee Ashuranse
If you only hear one song this year there's something terribly wrong
with you.



Re: RFC 253 (v1) UNIVERSAL::require()

2000-09-18 Thread John Porter

Michael G Schwern wrote:
 
 It all works.  

Mokay...


 DTRT?  Data Terminal Ready, Tim?  Document Filing and Retrieval Tedium?

Do The Right Thing, of course.

-- 
John Porter