> > > > Function calls in Perl are dead slow compared
> > > > to compiled languages.
> > > 
> > > Ok, so why is this?
> > > 
> > 
> > Implementation and little optimization.
> > 
> > Perl has a complex function calling mechanism, as
> > it flattens argument lists by pushing elements onto
> > the stack, records argument list length - the
> > number of arguments are variable in length.
> 
> Plus it keeps track of the call stack ... you can print out from 
> where you were called, from where your caller has been called and 
> so on.
>  
> > Unlike many compiled languages, Perl does not
> > inline short/frequently called functions - with
> > the result that speed suffers.
> 
> Well ... it does. But it only inlines the constant functions that have 
> been seen before they were used. And they have to be specified as 
> having no parameters!
> 

Useful :P

Okay... here's the comment the man at the top gave:

: Will function calls be faster in Perl 6, in general?  Using a simple
: benchmark, an empty subroutine called with no arguments took around
: 1500 machine cycles to execute on Perl 5.  Surely a nice new JIT and
: better VM should make function calls less expensive, tight loops in
: general are a bad idea in Perl 5 - no inlining.

Except for constants.

Perl 6 should be much better in this regard, provided you make use of
the formal parameter syntax.  The old way of setting up @_ with default
read/write parameters is one place that slows down Perl 5 subroutine
calls, so the newer signatures that default the argument list to being
constant should help the optimizer out a great deal, since it can then
just pull arguments straight from wherever they're stored, whether
stack or register.  The JIT (which already exists!) will also help,
hopefully.

Larry [Wall, on the perl6-language mailing list]

---

I suggest you don't bother Larry about it.. I asked when it was
reasonably appropriate and relevent to the discussion.  (A thread
on whether tail recursion would be optimised in Perl 6).

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to