in reply to Re: Perl and Objects, how do you resolve the two?
in thread Perl and Objects, how do you resolve the two?
Try it out on me. :-)
First of all I would not advocate using AUTOLOAD for everything. But there are cases where it is a useful tool to know about. Use it wisely.
For instance how would you write the equivalent of Re (tilly) 1: Nested Classes without AUTOLOAD? (At least and make it look like Perl's object syntax.)
And yes. There is a performance hit. Which is why people play games like I did at Re (tilly) 1: Reverse Inheritance Irritance and auto-instantiate real methods. You pay the price of the AUTOLOAD once only per method that you use. Incidentally the pattern that I used in that post is a common one to see in a lot of OO languages. Generally done with some version of AUTOLOAD.
So I hope that by practical example you see that there are things that AUTOLOAD is truly useful for. No, it should not replace everything under the sun. But it is a legitimate part of the toolkit.
As for the example that you showed, my main complaint is that you are not using strict. Also I would want to export the functions from Global::Generic_Object using Exporter. Beyond that, I would need to know what your definition of medium sized is. If you mean a few thousand lines, I think you are waaay over-engineering it. If you mean 30,000, well I wonder about over-engineering. In a larger application? Plausible. But I would want to see the object model.
In short, I would worry that is a design meant to support an object model that has grown out of control...
As for whether Perl's OO really is, well it is simplistic, it is a little wordy, performance isn't great, but you can do OO and it works. You can play fun OO games and it works. You can lay something complex out and it works.
But if you want OO nirvana, well Perl supports a lot of styles of programming as "second class citizens", OO among them. Perl is not the greatest language for OO. But it works...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re (tilly) 2: Perl and Objects, how do you resolve the two?
by satchboost (Scribe) on Apr 11, 2001 at 19:25 UTC | |
by tilly (Archbishop) on Apr 11, 2001 at 20:26 UTC | |
by satchboost (Scribe) on Apr 11, 2001 at 22:05 UTC |