Learning About Ada Variables

I’ve written an article about Ada variables and constants for our Wiki. It’s an article primarily aimed at beginning programmers.

Variables and constants both store data. The difference between them is that the data stored in a variable can be changed during program execution, whereas the data stored in a constant cannot. Both must be declared as a specific type, but only the constant requires a value to be assigned when it is declared.

In Ada, variables and constants are actually called objects. This has nothing to do with object oriented programming. A variable in Ada is an object that has been declared as a given type and with an optional initial value. A constant is the same, except the declaration now contains the reserved word “constant” and the initial value is no longer optional, but required.

If the above is old news to you, chances are you’re already way past the point where any benefits can be gained by reading the article.

But if you’re a beginner, this might be a good place to start.

For the next beginner article, I intend to try and tackle the huge subject of Ada types and subtypes, so stay tuned!

Leave a Reply