A collection of introductory Ada examples.
To run an example, execute gnatmake example.adb
, then run the resulting binary.
Suggested order:
- hello_world.adb - first Ada program
- prime.adb - control structure syntax
- lunch.adb - enumeration types, subtypes, and arrays
- bad_lunch.adb - run-time constraint errors, exception handler syntax
- access_types.adb - access types (pointers), records (structs), and dynamic memory allocation / deallocation. Example adapted from Ada Crash Course
- conditions.adb - pre-conditions and post-conditions
- tasking.adb - Simple concurrency
- threadsafe_containers, circbuf_example.adb - Concurrent message-passing through protected objects