"Ada Language Learning Notes" reference manual Chinese Translation and annotation--language overview

Source: Internet
Author: User
Tags case statement mathematical functions scalar



Ada language is required for our experiments in concurrent & distributed systems.

In layman's terms, the ADA language is a particularly detailed language (highly specific), so it is characterized by a large number of checks at compile-time and runtime that can pinpoint the wrong location and type more precisely (because the language itself is exhaustive, the more information you provide, The compiler can do more.)


This is the ADA's Reference manual.


An overview of the language in this translation manual (Language Summary).

Http://blog.csdn.net/iyundi


Language Summary11An Ada Program was composed of one or more program units. Program units may subprograms (which define executable algorithms), packages (which define collections of entities), TA SK units (which define concurrent computations), protected units (which define operations for the coordinated sharing of D ATA between tasks), or generic units (which define parameterized forms of packages and subprograms). Each program unit normally consists of a PARTS:A specification, containing the information that must is visible to othe R units, and a body, containing the implementation details, which need not being visible to other units. Most program units can compiled separately. The ADA program consists of one or more program units. The program unit can be Sub-Program(Define an executable algorithm), Package(Define a collection of entities), Task Unit(Define parallel compute cells), protected Unit(define the operation of shared data for collaboration between tasks) or Generic Unit(Define parameterized packages and subroutines). Each program unit is usually made up of two parts: Defining Segments(specification)--contains information that should be visible to other cells, and Body Segment(body)-Contains the details of the implementation without being seen by other units. Most program units can be compiled independently. Note: In the experiment Guide there is another sentence: in Ada those, aspects is separated into the separate source files which will be independently compil Ed. The two sections are located in two separate original files and will be compiled independently of each other. 12This distinction of the specification and body, and the ability to compile units separately, allows a program to be desi Gned, written, and tested as a set of largely independent software components. Defines the separation of segments from entity segments, and the ability to compile different units separately, enabling a program to act as a set of highly independent software Components are designed, written and tested. 13An Ada program would normally make use of a library of program units of the general utility. The language provides means whereby individual organizations can construct their own libraries. All libraries is structured in a hierarchical manner; This enables the logical decomposition of a subsystem to individual components. The text of a separately compiled program unit must name the library units it requires. ADA programs typically take advantage of the program Unit library as a common tool. This language provides a number of ways to enable different organizations to build their own libraries. All libraries are organized in a hierarchical structure: This allows a subsystem to be logically decomposed into separate components. Individually compiled program unit text must indicate the name of the library unit it requires. 14 Program Units Program Unit15A Subprogram is the basic unit for expressing an algorithm. There is kinds of subprograms:procedures and functions. A procedure is the means of invoking a series of actions. For example, it may read data, update variables, or produce some output. It may be parameters, to provide a controlled means of passing information between the procedure and the point of call. A function is the means of invoking the computation of a value. It is similar to a procedure, but in addition would return a result. Sub-ProgramIs expression AlgorithmThe basic unit. There are two seed programs: process (procedure) and function. The process is to invoke a series of actions. such as reading data, updating variables, generating output. It can be used to pass information between the call point and the process (procedure) in a controlled manner by means of tangible parameters. The function is to call a calculation procedure to get a value. It is much like a process, but returns an extra result. 16A package is the basic unit for defining a collection of logically related entities. For example, a-package can is used to define a set of type declarations and associated operations. Portions of a package can is hidden from the user, thus allowing access only to the logical properties expressed by the PA Ckage specification. Package(package) is define a logically interconnected set of entitiesThe basic unit. For example, a package can be used to define a set of (data) type declarations and related operations (for that data). Some parts of the package can be transparent to the user, allowing access only to the logical properties expressed by the definition segment of the package. 17Subprogram and package units is compiled separately and arranged in hierarchies of the parent and child units giving fin E control over visibility of the logical properties and their detailed implementation. Subroutines and packages can be compiled separately and organized in a hierarchical structure of parent-child units to implement logical attributes and achieve precise control of the visibility of the details (both). Note: Subroutines and packages are program units, which are conceptually tied together. 18A Task Unit is the basic unit for defining a task whose sequence of the actions could be executed concurrently with those of O ther tasks. Such tasks May is implemented on Multicomputers, multiprocessors, or with interleaved execution in a single processor. A task unit may define either a single executing task or a task type permitting the creation of any number of similar task S. Task Unitis the basic unit for defining tasks (nonsense ...). )。 A task consists of a series of actions (actions) that can be used to manipulate sequences of other tasks in parallelPerform. 19/2 A protected Unit is the basic unit for defining protected operations for the coordinated use of data shared between T asks. Simple mutual exclusion are provided automatically, and more elaborate sharing protocols can be defined. A protected operation can either is a subprogram or an entry. A protected entry specifies a Boolean expression (an entry barrier) that must being True before the body of the entry is exec Uted. A protected unit may define a single protected object or a protected type permitting the creation of several similar objec Ts. protected Unitis defined operations on shared data between collaborative tasksThe basic unit. Simple mutexes can be implemented automatically, and users can define more complex and sophisticated sharing protocols themselves. A protected operation can be a subroutine, or it can be an item (entry). A protected item specifically defines (specifies) A Boolean expression (an entry barrier: A barrier/guard for an item): Only if the expression is true, the body of the item can be executed. A protected unit can define a single protected object, or it can define a protected type, allowing programmers to create a class of similar objects. 20 Declarations and statements declaring statements and executing statements21The Body of a program unit generally contains-parts:a declarative part, which defines the logical entities to be US Ed in the program unit, and a sequence of statements, which defines the execution of the programs unit. Body SegmentIt usually consists of two parts: the declaration part--defining the logical entity to be used in the program unit, and executing the statement sequence--defining the execution of the program unit. NOTE: Program unit = Declaration Segment + Body segment, body segment = declaration Statement part + EXECUTE statement part. --22the Declarative part associates names with declared entities. For example, a name is denote a type, a constant, a variable, or an exception. A declarative Part also introduces the names and parameters of other nested subprograms, packages, task units, protected U NITs, and generic units to being used in the program Unit. The Declaration statement Section associates the name with the entity being declared. For example, a name might represent a type, a constant, a variable, or an exception. The Declaration statement Section also introduces the names and formal parameters of other nested subroutines, packages, task units, protected cells, and generic cells that are used by the program unit. 23The sequence of statements describes a sequence of actions that is to be performed. The statements is executed in succession (unless a transfer of control causes execution to continue from another place). The line statement sequence describes the sequence of operations that should be performed. Statements are executed sequentially (unless there is a control transfer statement that causes the program to jump to another location to continue execution). 24An Assignment statement changes the value of a variable. A procedure call invokes execution of a procedure after associating any actual parameters provided at the call with the CO rresponding formal parameters. Assignment statements change the value of a variable. Procedure CallThe corresponding formal parameters of the incoming real participation in the call are contacted before the execution of the process is triggered. 25Case statements and if statements allow the selection of a enclosed sequence of statements based on the value of an exp Ression or on the value of a condition.case statement and if statement expresses a choice based on the value of an expression or condition, followed by a sequence of statements that should be executed after each selection. 26The Loop Statement provides the basic iterative mechanism in the language. A loop statement specifies that a sequence of statements are to being executed repeatedly as directed by an iteration scheme, The or until an exit statement is Encountered.loop statement provides a basic iteration mechanism. The loop statement represents repeating a series of statements, or following a certain iteration rule, or execution until an exit statement is encountered. 27A Block statement comprises a sequence of statements preceded by the declaration of local entities used by the statement The S.block statement contains a series of statements that closely follow the part of the local entity declaration that it will use. 28Certain statements is associated with concurrent execution. Some statements are related to concurrent execution. A delay statement delays the execution of a task for a specified duration or until a specified Time. delay statement delays a task's , or delay a specified period of time, or delay it until a specific time. An entry call statement are written as a procedure call statement; It requestsAn operation to a task or on a protected object, blocking the caller until the operation can is performed. A called task may accept a entry call by executing a corresponding Accept statement, which specifies the actions and to Being performed as part of the rendezvous with the calling task. An entry call on a protected object was processed when the corresponding entry barrier evaluates to True, whereupon the BOD Y of the entry is executed. entry a call statement written like a procedure invocation statement; It requests the operation of a task or protected object, blocking the caller until the operation can be executed. The called task can accept a entry call in a way that executes the corresponding Accept statement, ... The Requeue statement permits the provision of a service as a number of related activities with preference control. One form of the SELECT statement allows a selective wait for one of several alternative rendezvous. Other forms of the SELECT statement allow conditional or timed entry calls and the asynchronous transfer of control in Res Ponse to some triggering event .... 29Execution of a program unit could encounter error situations in which normal programExecution cannot continue. For example, an arithmetic computation could exceed the maximum allowed value of a number, or an attempt could be made to ACCE The SS an array is component by using the incorrect index value. To deal with such error situations, the statements of a program unit can is textually followed by exception handlers that Specify the actions to is taken when the error situation arises. Exceptions can raised explicitly by a raise statement. The execution of the program unit may encounter an error, causing the program's normal execution to not continue. For example, the result of an algebraic calculation may exceed the maximum representation range, or the array will be out of bounds. To handle these error conditions, the statement of the program unit can be followed directly by the exception-handling statement (exception handlers), which defines the action to take when an error occurs. An exception can be thrown by an explicit raise statement. 30 Data Types Data Type31Every object in the language have a type, which characterizes a set of values and a set of applicable operations. The main classes of types is elementary types (comprising enumeration, numeric, and access types) and composite types (in cluding array and record types). Each object has a type that depicts a series of values and a set of legitimate actions. Types fall into two main categories: basic types (including enum-type enumeration, numeric type numeric, and some access-type access types) and combined types (including arrays and records (structs)). 32/2 an enumeration type defines an ordered set of distinct enumeration literals, for example a list of states or an Alphabet of characters. The enumeration types Boolean, Character, Wide_character, and Wide_wide_character are Predefined. Enumeration types define an ordered set of enumerated text, such as a list of States or an alphabet of characters. The predefined enumeration types are Boolean Boolean, character Character, wide character type wide_character, and wide-width character wide_wide_character. Orz33numeric types provide a means of performing exact or approximate numerical. Exact computations use integer types, which denote sets of consecutive integers. Approximate computations use either fixed point types with absolute bounds on the error, or floating point types, with relative bounds on the error. The numeric types Integer, Float, and Duration are predefined. Numeric types can be used to perform precise or approximate numerical calculations. An exact calculation uses integral type (integer) to define a contiguous set of integers. Approximate or use fixed-point decimal types (defining the absolute range of errors), or use floating-point decimal types (defining the relative range of errors). The predefined numeric types are integer integer, float float, and duration type. 34/2 composite types allow definitions of structured objects with related components. The composite types in the language include arrays and records. An array is a object with indexed of the same type. A record is an object with named of possibly different types. Task and protected types is also forms of composite types. The array types String, wide_string, and wide_wide_string are predefined. Composite types allow you to define structured objects that are composed of related components. Composite types include arrays and struct bodies. An array is the whole of an ordered sequence of data of the same type, where each element corresponds to an index. A struct consists of the whole of a named member that may be of different types. Task types and protected types are also composite types. Predefined types have strings, wide strings, and wide-width strings ... 35Record, task, and protected types may has special components called discriminants which parameterize the type. Variant record structures that depend on the values of discriminants can be defined within a record type. structs, tasks, and protected types may have special members called discriminant, which make their owning type parameterized. Depending on the definition of the structure type, the composition of the structure can be changed according to the value of the discriminant formula. 36Access types allow the construction of linked data structures. A value of a access type represents a reference to an object declared as aliased or to an object created by the Evaluatio N of an allocator. Several variables of an access type is designate the same object, and components of one object may designate the same or Other objects. Both the elements in such linked data structures and their relation to other elements can is altered during program Execut Ion. Access types also permit references to subprograms to being stored, passed as parameters, and ultimately dereferenced as part of an indirect calls. Access types allow the creation of chained data structures (similar to pointers, so-called "access" ...). )。 The value of a pointer type represents a reference to an object that is defined as a "nickname", or an object that is obtained by the allocator evaluation. Several different variables of a pointer type can point to the same object, and the members of an object can point to the same or another object. The two elements in this chained data structure and their relationships can be changed at run-time. Pointer types also allow references to child programs, store them, pass them as arguments, and eventually dereference as part of an indirect call. 37Private types permit restricted views of a type. A private type can be defined in a packaGE so is the logically necessary properties is made visible to the users of the type. The full structural details is externally irrelevant is then only available within the package and any child units. Private types allow you to restrict the viewing of a type. Private types can be defined within a package, and only logically required properties are set to be visible to the user. The complete structural details unrelated to the outside world are visible only within the package and its subclasses. 38From any type a new type is defined by derivation. A type, together with its derivatives (both direct and indirect) Form a derivation class. Class-wide operations may is defined that the accept as a parameter an operand of any type in a derivation class. For record and private types, the derivatives is extensions of the parent type. Types that support these object-oriented capabilities of class-wide operations and type extension must is tagged, so The specific type of an operand within a derivation class can is identified at run time. When an operation of a tagged type are applied to an operand whose specific type are not known until run time, implicit disp Atching is performed based on the TAG of the operand. Any new type must be defined as an inheritance of other types. A type and its successors (both direct and indirect) make up an inheritance class. A class-level operation can be defined as an operator that receives any type of the class as an operand with a parameter. For structs and private types, inheritors can be extensions of the parent class. Those types of inter-class operations and type extensions that support OO performance must be marked so that each particular type of an operator in the inheriting class can be recognized at run time. Implicit allocations based on their tags will be executed when the operation of the tagged type is applied to an operator that corresponds to a specific type of operand until the runtime is known. 38.1/2   interface types provide abstract models from which other interfaces and types could be composed and Derived. This provides a reliable form of multiple inheritance. Interface types may also is implemented by task types and protected types thereby enabling concurrent programming and Inhe Ritance to be merged. The interface type provides an abstract model, using which other interfaces or types can be assembled or exported. The interface type provides a reliable form of multiple inheritance. Interface types can also be applied to task types and protected types to implement parallel programs and inheritance that will be merged. 39The concept of a type is further refined by the concept of a subtype, whereby a user can constrain the set of allowed VA Lues of a type. Subtypes can used to define subranges of scalar types, arrays with a limited set of index values, and records and Priva Te types with particular discriminant values. The concept of type can be further refined with subtypes (subtype), where, a user can qualify a set of allowable values for a type. Subtypes can be used to define a scalar's sub-range, an array of sub-bounds, and a specific value of the discriminant of a struct, a private type. 40 Other Facilities Other Tools41/2 aspect clauses can be used to specify the mapping between types and features of a underlying machine. For example, the user can specify this objects of a given type must be represented with a given number of bits, or that th e components of a record is to be represented using a given storage layout. Other features allow the controlled use of a low level, nonportable, or implementation-dependent aspects, including the dire CT insertion of machine code .... 42/2 the predefined environment of the language provides for input-output and other capabilities by means of Library packages. Input-output is supported for values of user-defined as well as of predefined types. Standard means of representing values in display form is also provided. Io is included in the standard library package and supports user types and predefined types. ...... 42.1/2   the predefined standard library packages provide facilities such as string manipulation, containe RS of various kinds (vectors, lists, maps, etc), mathematical functions, random number GENeration, and access to the execution environment. String operations, containers (vectors, linked lists, mappings, and so on), mathematical equations, random number generators, and run-time environments are also included in the standard library package. 42.2/2   the specialized annexes define further predefined library packages and facilities with emphasis on Areas such as real-time scheduling, interrupt handling, distributed systems, numerical computation, and High-integrity Sy Stems.43finally, the language provides a powerful means of parameterization of program units, called Generic program units . The generic parameters can be types and subprograms (as-well as objects and packages) and so, general algorithms and Data structures to is defined that is applicable to all types of a given class.  support generics. ......

adjourned

A very good resource is also attached: Http://wenku.baidu.com/view/d7e075c68bd63186bcebbc2c.html?re=view

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"Ada Language Learning Notes" reference manual Chinese Translation and annotation--language overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.