The result of a function can be set by setting the result variable: this can be the function identifier or, (only in ObjFPC or Delphi mode) the special Result identifier:
In Delphi or ObjFPC mode, the above can also be coded as:
As an extension to Delphi syntax, the ObjFPC mode also supports a special extension of the Exit procedure:
The Exit call sets the result of the function and jumps to the final End of the function declaration block. It can be seen as the equivalent of the C return instruction.
Remark Function results are treated as pass-by-reference parameters. That is especially important for managed types: The function result may be non-nil on entry, and set to a valid instance of the type.