in reply to Global Super Class (equivalent of java.lang.Object)
Java and Perl approach things differently. Let's look at the methods Object provides...
| Java | Perl |
|---|---|
| clone | nothing standard; depends on object model being used |
| equals | == |
| finalize | DESTROY |
| getClass | ref |
| hashCode | refaddr |
| notify | not sure; thread related |
| notifyAll | not sure; thread related |
| toString | "" |
| wait | not sure; thread related |
| ? | UNIVERSAL::can |
| ? | UNIVERSAL::isa |
| ? | UNIVERSAL::VERSION |
As you can see, Java doesn't stuff much into Object, but those things are deemed necessary for every object to be able to do. UNIVERSAL has some introspective methods; the other things that have to be in a class (in Java) are language features, either as operators or built-ins, and are mostly all applicable to non-object-oriented programming as well as OO.
If your project has some "universal" things that all the objects need to do, then by all means define a base class for all of your objects. That lets you make your system behave the way you need it to while not (potentially) breaking it for code you include from elsewhere.
|
|---|