Your full service technology partner! 
-Collapse +Expand
Search Delphi Group:

-Collapse +Expand Delphi To/From
-Collapse +Expand Delphi Store

Prestwood eMagazine

March Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi for W...Language Det...   Print This     
  From the September 2010 Issue of Prestwood eMag
Delphi Language Details:
Delphi Inlining (Inline)
Posted 14 years ago on 2/4/2009
Delphi Code Snippet:
 A flashcard from our Delphi Flashcards Library
 A code snippet from our Delphi Code Snippets Page
 Tags: Delphi , Inlining


General Info: Inline Routines

Instead of calling a routine, you move the code from the routine itself and expand it in place of the call. In addition to manual inlining, some languages support automatic inlining where the compiler or some other pre-compiler decides when to inline a code routine. Also, some languages allow for developer defined inlining where the developer can suggest and/or force the inlining of a code routine. Inlining can optimize your code for speed by saving a call and return, and parameter management.

Languages Focus: Inlining

Does it support inlining? If so, does it support developer defined inlining? Does it support automatic inlining? Both?

Delphi Inlining

Delphi introduced developer defined function and procedure inlining with Delphi 2005. Use the inline keyword to tell the compiler to try to inline a routine (a compiler hint). Since Delphi will only try to inline the routine, make sure you test for speed because inlining a routine can lead to slower code under some circumstances.

Syntax Example:
function Add(a, b: Integer): Integer; inline;

More Info

Definition:  Inline Routines


Share a thought or comment...
Comment 1 of 1

Inlining is a great concept, and a potentially powerful optimization.  Before using it, though, be sure to read Delphi's help about Inline.

Delphi 2006, for example, help has some very explicit things to say about inline.  Among them:

  • The inline directive is a suggestion to the compiler. It won't necessarily be observed.
  • There are a number of cases in which inlining will not occur.
  • Inlining will not occur on any form of late-bound method.  This includes virtual, dynamic, and message methods.
  • Routines that are not defined before use cannot be inlined.
  • Routines  that take open array parameters cannot be inlined.
  • Procedures and functions used in conditional expressions in while-do and repeat-until cannot be expanded inline.

There are other limitations, so be sure to read Delphi help.

Posted 14 years ago
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1283A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.


1 Advanced Level Question

Question #1: Multiple Choice

The correct syntax to inline a function is...

function DoSomething; __forceinline;
function DoSomething; inline;
_inline function DoSomething;

All of the above.


None of the above. Delphi does not support inlining even in later versions of Delphi such as Delphi 2005 and above.

 KB Article #101861 Counter
Since 2/4/2009
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site:

©1995-2023 Prestwood IT Solutions.   [Security & Privacy]