Syntax Cheat Sheet
Names used in examples
Concept | Ada |
Reference | Access |
Pointer | Access All |
Namespace | P, Q, R |
Class | Capricorn |
Struct | Scorpio |
Type | S, T, V, W |
Variables | A, B, C |
Function | Foo, Bar |
Overview
Identifiers | Can't start with number or underscore, case insensitive |
Keywords | Case insensitive, usually lower case |
Naming Conventions(s) |
|
Declaration file | FileName.ads |
Definition file | FileName.adb |
Dependency |
|
Line comment |
|
Block comment | N/A |
Inline docs | Line comment before or after element |
Program Structure
Compile-time config | N/A |
Static assert |
|
| |
Namespacing |
|
Child Namespaces |
|
Namespacing |
|
Namespace aliasing |
|
Using namespace |
|
Using subprograms of type |
|
Scope resolution |
|
| |
| |
| |
Ensuring module has no state |
|
No module initialization required |
|
Ensure elaboration immediately after specification |
|
Ensure other package is initialized before this one |
|
Ensure other package and all dependencies are initialized before this one. |
|
Prevent a dependency on another package |
|
Memory
Pointer |
|
Pointer to allocation from a specific pool |
|
Pointer deference |
|
Reference |
|
Variable used by Pointer |
|
Address |
|
Address |
|
Constant pointer |
|
Pointer to constant |
|
Constant pointer to constant |
|
Prevents allocations to anonymous access types. |
|
| |
Dynamic allocation |
|
Special Notations
Equality |
|
Inequality |
|
Assignment |
|
Array Access |
|
Range |
|
"Box" |
|
Exponentiation |
|
Discrete type |
|
"Tick" |
|
String Concatenation |
|
Expressions
qualified expression |
|
qualified expression |
|
if expression |
|
case expression |
|
Expression renaming |
|
Mathematics
Modify in-place |
|
Modulus |
|
Remainder |
|
Exponentiation |
|
Bit shifting | In standard library |
Control Flow
if |
|
while |
|
do-while |
|
value-based loop |
|
iterator-based loop |
|
Multiple choice |
|
Iterate over enum |
|
Stop iterating |
|
Start exception handling |
|
Empty statement (pass) |
|
Label |
|
goto |
|
Boolean Algebra
Equality |
|
Inequality |
|
Not |
|
Boolean operators | |
or |
|
and |
|
Short circuiting boolean operators | |
or |
|
and |
|
Exclusive-Or (XOR) |
|
Implies (not A, or B) |
|
Functions and Procedures
Procedure |
|
Function |
|
Subprogram call (no parameters) |
|
Subprogram call with named Parameters |
|
Override specifier |
|
Ensure that a subprogram definition does not override an existing one |
|
Pass by pointer |
|
Pass by reference |
|
Inline |
|
Using functions for a type unqualified. |
|
| |
Modifiable parameters |
|
Expression function |
|
Empty procedure |
|
Types
Statically sized array |
|
Array Access |
|
Multi-dimensional Array |
|
Built-In Variable length array |
|
Semantic type |
|
Range checks on type |
|
Size |
|
Alignment |
|
Type Aliasing |
|
Type parameterized by value (run-time) |
|
Enum range |
|
Membership test |
|
| |
Type invariant checks |
|
Sum types |
|
Coercion (casting) |
|
Coercion with constraint check(casting) |
|
Object-Oriented Programming
Class-like |
|
Abstract class |
|
Subprogram call of object-like type |
|
Subprogram call of object-like type (alternative function-style form) |
|
Member access from pointer |
|
| |
Prevent copying |
|
Inheritance |
|
Dynamic dispatch (virtual function call) |
|
Prevent implicit cast |
|
Runtime type checking |
|
Passing parameter by base class |
|
Array-like indexing of user-defined type. |
|
Automatic dereference of a handle-type to the handle's contents. |
|
Iterator for loops for user-defined types. |
|