in reply to Perl keyword like the C/C++ keyword 'inline'

Perl5 has (unfortunately) no macro system.

Maybe codefilters (see Filter::Simple) were meant to replace them, but I don't recommend their use.

Anyway perl knows the term "inlining" for subs but they are restricted to constant return values only (see Constant Functions)

An other approach would be dynamic code generation with a template-system and eval.

One more could be to use labels and gotos to avoid the function overhead. (you can also goto directly into a functionbody, but you have to take care by your self how to get back to the caller ...)

Anyway perl is not meant for these kinds of optimizations, the original concept was to delegate time critical tasks to embedded c code (see perlxs)

Cheers Rolf

UPDATE:added some links

  • Comment on Re: Perl keyword like the C/C++ keyword 'inline'

Replies are listed 'Best First'.
Re^2: Perl keyword like the C/C++ keyword 'inline'
by sadarax (Sexton) on Sep 29, 2009 at 08:47 UTC

    Thanks for the thoughts and suggestions. I will read up on those. I think I can already tell more than a few will at least be useful for investigating.

    About whether or not these would be appropriate, I'm not even sure if I would these optimizations after I successfully created them. I will do some profiling to see how things perform with and without.

    Mostly I am just morbidly curious to know about the inlining process and similar optimization processes.