wtd
|
Posted: Sat Oct 09, 2004 12:44 am Post subject: [Ada-tut] Basic program structure and using the compiler |
|
|
Basic Structure
The basic structure of an Ada 95 program is a procedure. The file name should match the name of the procedure, but be all lower case and the file extension should be ".adb".
code: | procedure Hello_World is
begin
-- code to be executed here
end Hello_World; |
This is about as simple as an Ada 95 program gets.
Compiling
The Ada compiler is quite simple to use. To compile the above program we would simply type:
code: | C:\> gnat make hello_world |
And since gnat compiles programs to native executables, you can simply run the program with:
A few quick notes
Ada 95 is case-insensitive. The names Hello_World, hello_world, and Hello_world are all identical to the compiler. For the sake of readability it's best to continue using the same version, though. It's just icing on the cake that the compiler doesn't punish you for forgetting to hold the shift key down.
Since Ada is case-insensitive, it's best to separate individual words that make up a variable, module, function, or procedure name with an underscore.
Is much more easily read than:
Additionally, upcasing the first letter in each word appears to be an Ada tradition, and serves a useful purpose, since it even more clearly delimits the beginning of each word.
Instead of:
|
|
|