Extended syntax

 

Type          Switch

Syntax      {$X+} or {$X-}

{$EXTENDEDSYNTAX ON} or {$EXTENDEDSYNTAX OFF}

Default     {$X+}

{$EXTENDEDSYNTAX ON}

Scope       Global

 

Remarks

Note:          The $X directive is provided for backward compatibility. You should not use the {$X-} mode when writing Delphi applications.

The $X directive enables or disables Delphi's extended syntax:

·   Function statements. In the {$X+} mode, function calls can be used as procedure calls; that is, the result of a function call can be discarded, rather than passed to another function or used in an operation or assignment. Generally, the computations performed by a function are represented through its result, so discarding the result makes little sense. Sometimes, however, a function is called because it performs a task such as setting the value of a global variable, without producing a useful result.

·   The Result variable. In the {$X+} mode, the predefined variable Result can be used within a function body to hold the function's return value. For more information, see "Function declarations" in the Object Pascal Language Guide

·   Null-terminated strings. In the {$X+} mode, Pascal strings can be assigned to zero-based character arrays (array[0..X] of Char), which are compatible with PChar types. For more information, see "Working with null-terminated strings" in the Object Pascal Language Guide.

 

Compiler directives (list)