Variables in Ada
In Ada, variables are explicitly declared and used by the compiler to ensure type-correctness of operations and function calls.
To run this Ada program:
In Ada:
- Variables are declared using the
name : type := value;
syntax. - The
constant
keyword is used for variables that won’t change after initialization. - Ada doesn’t infer types for variables. You must explicitly declare the type.
- Variables are automatically initialized to default values if not explicitly initialized.
- Ada doesn’t have a shorthand syntax for variable declaration and initialization like Go’s
:=
. - To print variables, we often need to convert them to strings using
Type'Image(variable)
. - String concatenation is done with the
&
operator.
Ada’s strong typing system and explicit declarations help catch errors at compile-time and make the code’s intent clearer.