On 1 Nov 2007 15:36:09 -0700, howa <[EMAIL PROTECTED]> wrote:

> So if I have an object, I don't have to pass its reference to function
> for performance gain?
>
> is that true?

What performance gain are you talking about?

When someone speaks of passing an object to a function in Perl, that
normally means passing a reference. There's no more efficient way to
pass an object as a parameter.

Normally, you should write your code in the way that makes sense to
you. Let Perl worry about whether it's performing as well as it
should; Perl is better at that task than you are, and it's probably
doing a pretty good job. Once your program is finished and debugged,
if you'd still like it to run faster, *then* you can profile it and
see what needs optimizing.

Having said that, I'll go so far as to say that, in general, an object
oriented program will run somewhat slower than the equivalent program
in a non-OO algorithm or language. If your goal is to make the program
run as fast as possible on the available hardware, you want something
low-level, like assembly language. One codes with objects not to make
the programs run as quickly as possible, but because OOP is a good way
to divide the task at hand into manageable pieces.

Cheers!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to