CPSC 320: Week 2
- History and goals of Ada
- More information on Ada (ie
documentation, tutorials, links)
- Compilation and the execution model
- More information on compilers
- Language Fundamentals:
Program structure, assignment, with and use, primitive types,
literals, operators, if and loop statements, text and numeric output
- Language Fundamentals (Continued):
Program structure, assignment, with and use, primitive types,
literals, operators, if and loop statements, text and numeric output
- Procedures and numeric input
- Notes from last year:
- Programming Assignment 1
- Reading (continued from last week): these sections discuss the
material we are covering this week.
- Chapter 1: all
- Chapter 1: sections 1-4
- Chapter 5: all
- Chapter 6: all sections except 3 and 6 (which we will cover later)
- Chapter 7: sections 1-3
- Key Topics for this week and next:
- Strings:
- Strings are fixed length and their length cannot be changed
- Strings are not references
- Strings are arrays of characters, and they can have slices
- Procedures can change their parameters - java cannot do this
- I/O of strings and characters
- Use get to input a character
- Use get to input a fixed length string of exact length (skips
newlines)
- Use get_line to input a string of unknown length but shorter than
some maximum length (if the string was not completely filled,
then the next get_line starts on the next line)
- More on input
- Use end_of_line to determine if input is at the end fo a line
- Use skip_line to move to the next line of input, ignoring
anything remaining on a line
- In interactive programs, EOF returns true when control D or
control Z is entered
- get causes an end error if it reads control D or control Z in an
interactive programs or if it attempts to do a read at end of file
in a program that reads from a file
- Use redirection to cause standard input (output) to read from (write
to) a file
- Exceptions
- Any begin/end block can have an exception clause
- When an exception occurs, control transfers to the exception
clause and then (normally) to the end of the enclosing begin/end block
- Begin/end block can be added anywhere in a program
- New exceptions can be declared just like variables
- Exceptions can be raised as needed
- Ada has 3 built-in exceptions: constraint_error, data_error,
program_error.
- Other exceptions are defined in packages (eg end_error) and/or
by the user (eg too_large)
- Assignment 1
- Readings:
- Exceptions: 2.6, 14.1 - 14.3 (you can skip 14.4)
- Input/Output: 20.6