You can’t see begin in an Ada function because a function body is written with is … end, not with a begin … end block the way a procedure is. In Ada, begin belongs to a sequence of statements, and a function does not contain one. A function body contains declarations (including the nested return statement’s expression) and then ends; there is no statement part between declarations and the closing end, so there is no place for begin to appear.
That one-sentence answer covers the common case, but the question usually comes from a specific kind of confusion. People who move from C-family languages, Pascal, or even from Ada procedures to Ada functions expect a keyword that marks “where the executable part starts.” In a procedure, that keyword is begin. In a function, the executable part is just the return statement, and Ada treats it as part of the function’s expression rather than as a statement sequence introduced by begin. Once you see the grammar that way, the missing begin stops looking like an omission and starts looking like a deliberate design choice.
The Structural Reason: Functions Return a Value, Procedures Execute Statements
An Ada subprogram body has a declaration part and, for procedures, a statement part. The statement part is introduced by begin and closed by end. A procedure looks like this:
The begin separates the declarations from the statements that run. A function cannot follow that pattern, because a function must produce a value, and Ada expresses that value through a return expression in the function body itself:
Wait — that example does contain begin. This is the first distinction that matters, and it is the one that most often trips people up: a function can contain begin in its body, but if you are looking at a function whose body has no begin, that is because the function is written in expression-function form. Both forms are legal and common, and the one without begin is increasingly what you see in modern Ada code.
An expression function writes the result directly after is, with no declarations and no begin:
This is a complete, legal function body. There is no begin because there is nothing to put between a begin and an end — no declarations, no statements, just the expression that the function returns. The parentheses are required around the expression, and the whole thing ends with a semicolon after the closing parenthesis. If you are grepping for begin and finding nothing, this form is almost certainly why.
So the precise answer has two layers. First, begin marks a statement sequence, and a function’s body is not required to have one. Second, Ada provides a function form — the expression function — that deliberately omits both declarations and begin, and that form is the one people encounter when they say they “can’t see begin for a function.”
How to Read an Ada Function Body
The cleanest way to stop being confused is to learn the shape of a subprogram body as a whole. An Ada subprogram body has this general structure:
| Part | Present in a procedure? | Present in a regular function? | Present in an expression function? |
|---|---|---|---|
| Name and parameter profile | Yes | Yes | Yes |
| is (or is new, is separate, etc.) | Yes | Yes | Yes |
| Declarations before the executable part | Optional | Optional | No |
| begin introducing the statement part | Yes | Yes | No |
| Statements (or the return statement) | Yes | Yes (must include a return) | No — the expression is the body |
| end with the name and semicolon | Yes | Yes | The expression form closes with ); the full declaration still ends with end and a semicolon in many contexts |
A regular function with declarations looks like this:
Here you do see begin, and you should. The function needs a local variable and a conditional, so it needs a statement part. The begin tells the reader where execution begins after the declarations. If your function contains any statement other than a single return, Ada requires that statement part, and it requires begin.
An expression function is the opposite case: no declarations, no statements, just a value. That is why it has no begin. It is not a function “missing” a keyword; it is a different, more compact form that Ada added precisely so simple functions could be written without ceremony.
The Most Common Misreading: “Can’t See begin” Actually Means “Can’t Find the Body”
There is a second, equally common source of the same complaint, and it has nothing to do with expression functions. In Ada, a function can be declared in a package specification and defined in the package body or a separate subunit. When you open the specification, you see only the declaration:
There is no begin here because there is no body here at all. The body lives elsewhere:
If you search a file or a directory for begin and find nothing near the function name, check whether you are looking at a specification rather than a body. Specifications declare; bodies define. Only bodies can contain begin, and even then, only when they are not expression functions.
A closely related case is a function that is a renaming, a generic instantiation, or an abstract declaration. None of those has a statement part, and none will show a begin. For example:
This declares a function by instantiating a generic. There is no body to inspect, so there is no begin to find. If your search is for a specific function and you cannot locate its begin, the practical next step is to determine which of three things you are looking at: a specification, an expression function, or a body defined by renaming or instantiation.
What begin Actually Belongs To
It helps to be precise about what begin introduces, because that explains why functions are allowed to skip it. In Ada, begin opens a sequence of statements. Sequences of statements appear in:
Procedure bodies Function bodies that have declarations or more than one statement Block statements (declare … begin … end) Package bodies (for package initialization) Task bodies and protected bodies, in their own forms Exception handlers, which are attached to a statement part
A package specification has no begin, because a specification contains only declarations. A package body can have a begin and an exception part, but those are for elaboration and initialization, not for general execution. This is the same principle as the function case: begin marks where a statement sequence starts, and wherever there is no statement sequence, there is no begin.
The expression function fits this principle exactly. It has no statement sequence, so it has no begin. A reader who expects begin in every subprogram is applying a rule that Ada never had. The rule is not “every subprogram has a begin”; it is “every statement sequence is introduced by begin.” Expression functions have no statement sequence, so they have no begin.
Why Ada Allowed This in the First Place
The expression function is not a quirk; it solves real problems in Ada code. Many functions are simple transformations: arithmetic, field selection, conversions, predicates. Writing them with a full declaration part, a begin, a return, and an end adds noise that hides the one thing the reader cares about. The expression form makes the function’s meaning visible at a glance:
These are readable, compact, and — importantly — analyzable. The expression function form also interacts well with Ada’s contract system. Preconditions and postconditions can be attached to the function declaration, and the expression form keeps the body short enough that the contract and the implementation can be read together. That is a practical reason the form exists, not a purely aesthetic one.
There is also a semantic reason. The expression is evaluated as the function’s result; there is no scope for side effects, no local variables to inspect, and no control flow to trace. That makes expression functions easier to reason about and easier for tools to check. The absence of begin is a visible signal of that simplicity.
When You Must Have begin
The rule of thumb is simple: if the function body contains anything other than a single return with the value, you need a statement part, and a statement part needs begin. That includes:
Local declarations (variables, constants, nested subprograms) Conditional logic, loops, or case statements Multiple statements, including multiple return statements Exception handling blocks Calls whose results are stored before being returned
For example, a function that validates and normalizes input needs declarations and branches:
Here begin is mandatory, and its presence tells you the body is doing real work. The presence or absence of begin thus becomes a quick readability cue: no begin means “this function is a single expression,” and begin means “this function has a body with statements.”
Common Variations That Also Omit begin
Beyond expression functions, several Ada constructs look like function bodies but have no statement part, and each explains a sighting of “function without begin”:
Null procedures and abstract functions. An abstract function declared in a tagged type has no body; derived types provide it. You will never see begin because there is nothing to execute.
Interface subprograms. Ada 2005 interfaces declare functions that implementers define. The interface itself contains only a declaration.
Aspects and contracts. A function declaration with pre/postconditions is still a declaration; the body is elsewhere. The contract does not include begin.
Generic formal functions. These are parameters, not implementations. They have a profile and no body.
Separate subunits. A function body can be compiled separately, but when you open the body file you will still see is … and either an expression or a begin…end block. If you see neither, you are probably looking at a stub.
In all of these, the answer is the same: you are not looking at an executable body, so there is no begin to see. The keyword is not conditionally omitted; the body is simply not there. Distinguishing “body without begin” (expression function) from “no body at all” (declaration) is the key skill.
A Diagnostic Checklist
If a function in front of you has no visible begin, work through these questions in order:
1: Is this a specification or a body? Look for package … is versus package body … is, or for the file extension conventions your project uses. A specification cannot contain begin. 2: Is the function followed by is ( and a closing )? If so, it is an expression function, and the absence of begin is correct and intentional. 3: Is the function declared with is new, is abstract, or as an interface primitive? Then it has no body in this unit; the body is instantiated or inherited elsewhere. 4: Does the body contain declarations or multiple statements? If yes and you still see no begin, look more carefully; a regular function body with a statement part must have begin, so something else is going on — possibly a macro, a preprocessing step, or a truncated file. 5: Is the begin present but far from the function name? In large bodies, the declaration part can be long. Search from the is keyword forward, not from the function name.
This checklist resolves nearly every “can’t see begin” report, because it forces the reader to identify which of the several legal forms they are reading.
Putting It Together
The direct answer is that begin is not a required marker for every Ada function. It is required only when the function body has a statement part, and many functions — especially those written as expression functions — do not have one. In those cases the body is a single expression enclosed in parentheses, terminated by a semicolon, and it contains no declarations, no statements, and therefore no begin.
That design is consistent with how Ada treats all statement sequences: begin introduces the part of a construct where statements execute. A function whose entire meaning is one expression has no such part, so it has no begin. If your search led you to a function with no begin and you expected one, the most likely explanations are that it is an expression function, that you are reading a specification instead of a body, or that the function is declared rather than defined. Checking those three possibilities tells you what you are looking at and why the keyword is absent.