Units and Namespaces

Units are the individual source code modules that make up a Delphi program. A unit is a place for you to group functions and procedures that can be called from your main program. To be a unit, a source module must consist of at least three parts:

  • A unit statement— Every unit must have as its first noncomment, nonwhitespace line a statement saying that it’s a unit and identifying the unit name. The name of the unit must always match the filename, excluding the file extension. For example, if you have a file named FooBar.pas, the statement would be

    unit FooBar;
  • The interface part— After the unit statement, a unit’s next functional line of code should be the interface statement. Everything following this statement, up to the ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.