Ada How was Ada conceived. The language, not the lady

advertisement
Ada
How was Ada conceived. The language, not the lady
Basic History
• 1970’s United States DoD decided to upgrade their entire software systems.
• Programming competition with a strict set of requirements held.
• Team from France led by Jean Ichbiah wins competition and created a new High
level language.
• Team names Language “Ada” after Lady lovelace(1815-1852)
• versions: Ada82, Ada85, Ada2005, Ada 2012,
A first Look
• One of the more flexible high level languages.
• Ada uses a procedure with no parameters.
• BEGIN and END defines the body of the procedure
• Sixty nine reserve words
• Operator symbols: =,/=,<,>.<=,>=,&,+,-,/,*
• Non symbol operators: and,or,xor,not,abs,rem,mod
Data Types
• Ada83 has no predefined inheritance hierarchy
• Ada allows you to define your own types and create new types.
• Enumerations types- Boolean values which are only True or False; NOT numeric
types.
• Modular types- ex.: Type byte is mod 2**8;
• Composite types- Record types are very similar to a struct in C.
• Task types-concurrent thread of execution.
• Other types include: Scalar types, access types, fixed/floating point types.
Loops
• For loops are relatively simple in every languages
• One of fundamental building blocks of any program is iteration.
• For loops can be used to traverse a 2-d arrays.
• The simplest loop is an unconditional loop…
Conditional statements
• The if statement: condition must always evaluate to a
Boolean value;
• Case statements: No need to explicitly break at the end of
each case.
• Avoid GoTo statements!!(unconditional statement)
subprograms
• Ada provides two kinds of subprograms
• Procedures never return a value…
• There are 3 passing modes for procedure parameters…
• Functions always return a value…
• Function parameters can only have the IN mode
Packages are all around us.
• The primary structure used for encapsulation is called a package.
• Used to group data and subprograms
• Usually consist of two parts, the specification and a package body.
• The package specifications…
• The package body…
A Very OOP language
• Created in the Ada95 version.
• Also brought inheritance to Ada…
• Derivation is used to let a new type inherit.
• Type extension is a direct link to type derivation…
• Extensible types aka tagged types..
Polymorphism
• When the compiler processes a function….
• Polymorphic behavior must be elicited within
parameterized procedure..
• Ada triggers polymorphic behavior through…
Exception Handling
• There are 5 predefined exceptions:
• CONTSTAINT_ERROR
• NUMERIC_ERROR
• PROGRAM_ERROR
• STORAGE_ERROR
• TASKING_ERROR
• What happens if there is no exception handler?
Concurrency
• Two models for concurrency:
• Tasking is implemented using Ada syntax.
• Each task is a sequential entity that may operate concurrently with and
communicate with other tasks.
• Once a task is created and activated…
Download