Chapter 1 – Language Basics
This chapter provides a foundational overview of the Delphi language as it stands in Delphi XE2. It covers the essential building blocks every Delphi developer needs: the structure of a program, how identifiers and the type system work, and the core constructs for controlling program flow.
What sort of language is Delphi?
Delphi is a statically typed, compiled, object-oriented language rooted in Object Pascal. It produces native executables and supports both traditional procedural programming and modern OOP paradigms. The chapter situates Delphi within the broader landscape of programming languages and explains what makes it distinctive for desktop and systems development.
The basic structure of a Delphi program
Every Delphi program follows a clear structural pattern built around units, the program keyword, and a well-defined entry point. The chapter walks through the anatomy of a typical console and GUI application, showing how the compiler resolves dependencies and assembles the final executable.
Identifiers and Typing in Delphi
Delphi's type system is strict and explicit. The chapter explains how identifiers are declared, the rules governing naming, and how the compiler enforces type compatibility. It introduces the distinction between value types and reference types, setting the stage for later chapters on classes, records, and memory management.
Additional Topics Covered
- Variables and constants — declaration, scope, and lifetime
- Looping constructs —
for,while, andrepeat..until - Conditional statements —
if..elseandcase - Procedures and functions — parameters, return values, and calling conventions
- Units — modular organisation and the
usesclause - Error handling — exceptions and the
try..except/try..finallyblocks - Pointers and dynamically allocated memory