Lectures Ada_1

Lectures Ada_1 - Ada(DoD 1983 Imperative Modula-2 Pascal like for programming in-large and real-time secure embedded military systems Parallel

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Ada (DoD, 1983) Imperative, Modula-2 & Pascal like for programming “in-large” and “real-time” “secure” embedded military systems. ** Parallel tasks (rendezvous). ** Robustness (exception mechanism) & reliability. ** Modularity & Info hiding & portability (package facility) ** Polymorphism (static): generic packages; overloading. ** Very rich (the richest) & strong typing system. * Back to Algol’s “blocks”: <name>: declare < decl-seq> begin <stmt-seq> [exception <exp-handler>] end [<name>] *Ada is case insensitive (FOO=foo). Ada reserved words (BOLD) Reserved words have special meaning. They cannot be used for any other purpose. abort abs accept access all and array at begin body case constant declare delay delta digits else elsif end entry exception exit for function generic goto if in is limited loop mod new not null of or others out package pragma private procedure raise range record rem renames return reverse select separate subtype task terminate then type use when while with xor For their use , see --> http://www.seas.gwu.edu/~adagroup/ada95-syntax/idxkeyword.html Pre-defined words Some other words have standard pre-defined meaning. Their meaning can be changed . .. with care ... but don't! BOOLEAN CHARACTER CLOSE CREATE DELETE FALSE FLOAT GET INTEGER NATURAL NEW_LINE OPEN PUT PUT_LINE POSITIVE READ RESET SKIP_LINE STRING TEXT_IO TRUE WRITE
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
i) : A: constant FLOAT := 1000.00 ; B: constant INTEGER := f(A); -- f is a function that returns integer E_C constant := 0.57721; Light_Year := 5_878_000_000_000 ; -- “ named number ” for readability There is no explicit type of the above “ named number ”, instead the compiler will assign it an internal “ universal ” (LONG_INTEGER) anonymous type. The reason is that to leave it for the compiler to decide, based on the underlying hardware, the suitable representation; hence to make programs portable. ii) Real types : the Ada compiler provides FLOAT, LONG_FLOAT, SHORT_FLOAT; with implementation-dependent accuracy; and not very portable. For portability the programmer indicates the required precision: type DISTANCE is digit 6 range 0.0 . . 100000.0 -- the programmer specifies his/her a 6 digits of accuracy in the “mantissa” FLOAT type, with range of values 0 to 10000! If the hardware can not provide, the compiler will reject; otherwise it will select one of the above REAL types. iii) Subtypes : type DAYS is (MON, TUE, WED, THUR, FRI, SAT, SUN); subtype BANKING_DAY is DAYS range MON. .FRI; subtype WEEK_END is DAYS range SAT. .SUN; subtype SHORT_TERM is INTEGER range 1..365; subtype ACCOUNT_BALANCE is DOLLAR range 100.00. .100_000.00; -- DOLLAR is user defined type subtype ACCOUNT_ID is POSITIVE range 1..1e9; -- POSITIVE all Integer values starting at 1 through the highest value of Integer -- NATURAL is a predefined subtype of Integer with a minimum value of 0 and a maximum value of the highest value of Integer . S : SHORT_TERM;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/23/2011 for the course CSE 324 taught by Professor Soliman during the Spring '11 term at NMT.

Page1 / 9

Lectures Ada_1 - Ada(DoD 1983 Imperative Modula-2 Pascal like for programming in-large and real-time secure embedded military systems Parallel

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online