Differences
This shows you the differences between two versions of the page.
variables_and_constants [2011/12/16 20:50] thomaslocke |
variables_and_constants [2013/02/21 08:31] (current) thomaslocke [Variables] |
||
---|---|---|---|
Line 23: | Line 23: | ||
Variable_Name : Variable_Type := Variable_Value | Variable_Name : Variable_Type := Variable_Value | ||
- | Lets try it with some real Ada variables. As seen above, a variable in Ada **must** be declared as pointing to a specific //type// of data: | + | Let's try it with some real Ada variables. As seen above, a variable in Ada **must** be declared as pointing to a specific //type// of data: |
<code ada> | <code ada> | ||
Line 61: | Line 61: | ||
</code> | </code> | ||
- | Notice the homegrown //Colors// type. First we declare the new type, and then we declare the //Color// variable the of that type. This is one of the biggest strengths of Ada: The ability to declare your own types and subtypes. More can be on this subject in the [[types and subtypes]] article. | + | Notice the homegrown //Colors// type. First we declare the new type, and then we declare the //Color// variable the of that type. This is one of the biggest strengths of Ada: The ability to declare your own types and subtypes. More can be found on this subject in the [[types and subtypes]] article. |
- | Now, lets try and use the above declared variables in an actual program: | + | Now, let's try and use the above declared variables in an actual program: |
<code ada> | <code ada> | ||
Line 145: | Line 145: | ||
Constants are an important tool to help make your programs more reliable and maintainable. A constant is, just like a variable, a reference to a specific //type// of data, but where they differ from variables is in their constant nature. Variables vary, constants are constant. When declared and initialized, the data they reference is static and can no longer be altered. If you try to alter a constant, the compiler will complain, loudly. | Constants are an important tool to help make your programs more reliable and maintainable. A constant is, just like a variable, a reference to a specific //type// of data, but where they differ from variables is in their constant nature. Variables vary, constants are constant. When declared and initialized, the data they reference is static and can no longer be altered. If you try to alter a constant, the compiler will complain, loudly. | ||
- | Lets see how we declare and initialize a constant: | + | Let's see how we declare and initialize a constant: |
<code ada> | <code ada> | ||
Line 218: | Line 218: | ||
==== Scope ==== | ==== Scope ==== | ||
- | Finally lets take a short look at variable scope in regards to blocks. When and where are they visible? This is perhaps best understood by a simple program: | + | Finally let's take a short look at variable scope in regards to blocks. When and where are they visible? This is perhaps best understood by a simple program: |
<code ada> | <code ada> |