2.8 compiler/language/debugging
there are many enhancements to the delphi compiler, language and debugger of delphi 2005.
compiler and language enhancements
several performance enhancements have been implemented for the delphi 2005 compiler, resulting in even faster compilation speeds. the compiler now also supports unicode and utf8 source code files, unicode characters in identifiers and symbols.
for ... in ... do
the delphi language has been extended with a new for-loop syntax, a bit similar to the foreach construct. this powerful new language feature can be used to iterate through a set of values.
function inlining
both the win32 and .net delphi languages are extended with function inlining, which can result in faster performance. instead of calling a routine, the code from the routine itself is expanded in place of the call (saving a call and return, as well as parameter management). this is especially beneficial for small routines, routines outside your unit scope, or routines with many parameters. for bigger routines, the trade-off between efficiency at the cost of bigger code size should be considered carefully before applying inline.
we can either inline routines explicitly with the inline directive, or use an {$inline auto} compiler directive. the latter will leave it up to the compiler to select routines for inlining that are likely to improve your performance. using {$inline on} you specify that a set of routines will all be inlined from that point on.
there are a number of exceptions regarding routines that cannot be inlined by the compiler. although you can inline routines from different units in a package (assembly), you cannot inline routines across package boundaries for example. it's also not possible to inline virtual, dynamic or message methods, as well as methods of interfaces and dispinterfaces.
multi-unit namespaces
the previous version of the delphi for .net compiler used a mapping of one unit per namespace (where the name of the unit would be the name of the namespace). this has been expanded in delphi 2005, where a namespace can now be made up of several units. with a unit name of for example comp.group.myunit.pas, the left-hand side comp.group is the name of the namespace, and myunit.pas the local unit scope within the namespace. this allows us to write multiple units and make them all belong to a single namespace (ideal for asp.net custom controls, that can now get a single control prefix).
as another consequence of this new namespace feature in delphi 2005, it's now also possible to use delphi 2005 in order to extend existing namespaces with our own functionality. for example the system.web namespace can be extended with classes and types from a system.web.myunit.pas unit. the namespace extension becomes part of any application or assembly that contains the system.web.myunit.pas.