Previous topic |
Next topic |
Ada Home Page |
Index
Program structure and layout
Example
----------------------------------
-- sum_prod - sum and product
----------------------------------
with ...;
use ...;
procedure program_name is
declare I/O packages
declare constants & variables used
begin -- program_name
statements
end program_name ;
Structure
header:
- identifying comments
- what does this procedure depend on
declarations:
- name
- libraries needed
- variables, constants, procedures
statements:
reserved words
have special meaning
Little restriction on layout of Ada programs
Common layout convention makes programs easier for others to read, understand,
maintain (and mark!)
Basic conventions:
- one statement (one thought) per line
- break long lines into readable segments
- indent lines to show different parts of program
- blank lines separate parts of the program
- comments help readers understand program
Previous topic |
Next topic |
Ada Home Page |
Index
c-lokan@adfa.oz.au / 12 Feb 96