e-book Ada 2005 Ref. Manual - Lang., Std. Libs.

Free download. Book file PDF easily for everyone and every device. You can download and read online Ada 2005 Ref. Manual - Lang., Std. Libs. file PDF Book only if you are registered here. And also you can download or read online all Book PDF file that related with Ada 2005 Ref. Manual - Lang., Std. Libs. book. Happy reading Ada 2005 Ref. Manual - Lang., Std. Libs. Bookeveryone. Download file Free Book PDF Ada 2005 Ref. Manual - Lang., Std. Libs. at Complete PDF Library. This Book have some digital formats such us :paperbook, ebook, kindle, epub, fb2 and another formats. Here is The CompletePDF Book Library. It's free to register here to get Book file PDF Ada 2005 Ref. Manual - Lang., Std. Libs. Pocket Guide.

Documentation libplexus-cipher-java-doc 1. Documentation libsvn-doc 1. Doc package libwerken. Documentation libwvstreams4. Documentation and examples lighttpd-doc 1. NET developers - docs monodoc-hyena-manual 0. NET monodoc-notify-sharp-manual 0. Comprehensive documentation pari-doc 2. Docs python-sfml-doc 2. Org-Fenstersystem xorg-docs-core Org xotcl-doc 1.

Tasks are the units of concurrent execution. Packages provide modular structure for the program, and are often used to implement abstract data types. A package can have separately compiled specification and implementation instances. Two languages known to have influenced the creation of Ada are Pascal and Euclid. Probably CLU was another source of influence regarding generic programming.

With some editions you compile programs for the same platform and operating systems on which you run the tools. These are called native. With others, you can produce programs for different operating systems and platforms. One possible platform is the Java virtual machine. These remarks apply to the native Microsoft Windows edition. You can run the translation tools either from the IDE or from the command line.

Whether you prefer to work from the IDE, or from the command line, a little bookkeeping is required. This is done by creating a project. Each project consists of a number of source files, and a number of settings like search paths for additional Ada libraries and other dependences. Each project also has at least one target. Typically, there is a debug target, and a release target. The names of the targets indicate their purpose.

Making and Working with Libraries in C++ (Multiple Projects in Visual Studio)

At one time you compile for debugging, typically during development, at other times you compile with different settings, for example when the program is ready for release. Some all commercial? DEC Ada uses a true library management system — so the first thing you need to do is create and activate a library:. So carefully read. The sources don't need to be perfect at this stage but syntactically correct enough for the compiler to determine the packages declared and analyze the with statements. Dec Ada allows you to have more than one package in one source file and you have any filename convention you like.

The purpose of ACS Load is the creation of the dependency tree between the source files. Note that compile take the package name and not the filename. The compiler automatically determines the right order for the compilation so a make tool is not strictly needed. On large systems you might want to break sources down into several libraries — in which case you also need.

The larger libraries should then be created with:. Once you have downloaded our example programs you might wonder how to compile them. First you need to extract the sources. Use your favorite zip tool to achieve that. On extraction a directory with the same name as the filename is created. You could compile them right there.

  • Ada (programming language) - Wikipedia.
  • What is wrong with NULL?.
  • Radiation Processing of Polymer Materials and its Industrial Applications?
  • Specific Principles of Kashmir Saivism!
  • The solution!
  • Account Options.

For your convenience we also provide ready made project files for the following IDEs If you find a directory for an IDEs not named it might be in the making and not actually work. For i Linux and Windows you can compile any demo using:. For other target platform it is a bit more difficult since you need to tell the project files which target you want to create. The following options can be used:. Remember to type all options as they are shown.

  1. Pragma Ada_83?
  2. Table of Contents.
  3. Comparison of programming languages?
  4. Ada Programming/All Chapters - Wikibooks, open books for an open world.
  5. To compile a debug version on x Linux you type:. As said in the beginning there is also a makefile available that will automatically determine the target used. So if you have a GNU make you can save yourself a lot of typing by using:. Empty directories are provided inside the archive. APEX uses the subsystem and view directory structure, so you will have to create those first and copy the source files into the view.

    Apex uses the file extensions. Double-click the executable to run it. You can use the shift-key modifier to bypass the link or run dialog. Before you can use the ObjectAda tools from the command line, make sure the PATH environment variable lists the directory containing the ObjectAda tools. Something like. A minimal ObjectAda project can have just one source file. To build an executable from this source file, follow these steps assuming the current directory is a fresh one and contains the above mentioned source file :.

    This makes your sources known to the ObjectAda tools. Have a look at the file UNIT. MAP created by adareg in the current directory if you like seeing what is happening under the hood. Notice that you specify the name of the main unit as argument to adabuild , not the name of the source file. More information about the tools can be found in the user guide Using the command line interface , installed with the ObjectAda tools. Conditional clauses are blocks of code that will only execute if a particular expression the condition is true. The if - else statement is the simplest of the conditional statements.

    They are also called branches, as when the program arrives at an if statement during its execution, control will "branch" off into one of two or more "directions". An if - else statement is generally in the following form:. If the original condition is met, then all the code within the first statement is executed. The optional else section specifies an alternative statement that will be executed if the condition is false.

    Exact syntax will vary between programming languages, but the majority of programming languages especially procedural and structured languages will have some form of if-else conditional statement built-in. The if-else statement can usually be extended to the following form:. Only one statement in the entire block will be executed. This statement will be the first one with a condition which evaluates to be true. The concept of an if-else-if structure is easier to understand with the aid of an example:.

    When this program executes, the computer will check all conditions in order until one of them matches its concept of truth. As soon as this occurs, the program will execute the statement immediately following the condition and continue on, without checking any other condition for truth. For this reason, when you are trying to optimize a program, it is a good idea to sort your if-else conditions in descending probability.

    Why Use Ada For Critical Code

    This will ensure that in the most common scenarios, the computer has to do less work, as it will most likely only have to check one or two "branches" before it finds the statement which it should execute. However, when writing programs for the first time, try not to think about this too much lest you find yourself undertaking premature optimization. Having said all that, you should be aware that an optimizing compiler might rearrange your if statement at will when the statement in question is free from side effects.

    Among other techniques optimizing compilers might even apply jump tables and binary searches. In Ada, conditional statements with more than one conditional do not use short-circuit evaluation by default. Often it is necessary to compare one specific variable against several constant expressions. For this kind of conditional expression the case statement exists.

    For example:. In Ada, one advantage of the case statement is that the compiler will check the coverage of the choices, that is, all the values of the subtype of variable X must be present or a default branch when others must specify what to do in the remaining cases. Unconditionals let you change the flow of your program without a condition.

    You should be careful when using unconditionals. Often they make programs difficult to understand. Read Isn't goto evil? One often hears that goto is evil and one should avoid using goto. But it is often overlooked that any return which is not the last statement inside a procedure or function is also an unconditional statement — a goto in disguise. There is an important difference though: a return is a forward only use of goto. Exceptions are also a type of goto statement; worse, they need not specify where they are going to!

    Therefore if you have functions and procedures with more than one return statement you can just as well use goto.

    Why Use Ada For Critical Code

    In practice, nearly every programmer is familiar with a 'return' statement and its associated behavior; thus, when it comes down to readability the following two samples are almost the same:. Because the use of a goto needs the declaration of a label, the goto is in fact twice as readable than the use of return. So if readability is your concern and not a strict "don't use goto " programming rule then you should rather use goto than multiple return s. Best, of course, is the structured approach where neither goto nor multiple returns are needed:. The endless loop is a loop which never ends and the statements inside are repeated forever.

    The term, endless loop , is a relative term; if the running program is forcibly terminated by some means beyond the control of the program, then an endless loop will indeed end. Naming loops is nice for readability but not strictly needed. Loop names are useful though if the program should jump out of an inner loop, see below. This loop has a condition at the beginning. The statements are repeated as long as the condition is met. If the condition is not met at the very beginning then the statements inside the loop are never executed.

    This loop has a condition at the end and the statements are repeated until the condition is met. Since the check is at the end the statements are at least executed once. Sometimes you need to first make a calculation and exit the loop when a certain criterion is met. However when the criterion is not met there is something else to be done. Hence you need a loop where the exit condition is in the middle. In Ada the exit condition can be combined with any other loop statement as well. You can also have more than one exit statement.

    You can also exit a named outer loop if you have several loops inside each other. Quite often one needs a loop where a specific variable is counted from a given start value up or down to a specific end value. You could use the while loop here — but since this is a very common loop there is an easier syntax available. You don't have to declare both subtype and range as seen in the example. If you leave out the subtype then the compiler will determine it by context; if you leave out the range then the loop will iterate over every value of the subtype given. As always with Ada: when "determine by context" gives two or more possible options then an error will be displayed and then you have to name the type to be used.

    Available CRAN Packages By Name

    Ada will only do "guess-works" when it is safe to do so. The loop counter I is a constant implicitly declared and ceases to exist after the body of the loop. Another very common situation is the need for a loop which iterates over every element of an array. The following sample code shows you how to achieve this:. With X being an array. Note: This syntax is mostly used on arrays — hence the name — but will also work with other types when a full iteration is needed. Ada's type system allows the programmer to construct powerful abstractions that represent the real world, and to provide valuable information to the compiler, so that the compiler can find many logic or design errors before they become bugs.

    It is at the heart of the language, and good Ada programmers learn to use it to great advantage. Four principles govern the type system:. Types are incompatible with one another. However, each type can have any number of subtypes , which are compatible with their base type and may be compatible with one another. See below for examples of subtypes which are incompatible with one another. There are several predefined types, but most programmers prefer to define their own, application-specific types. Nevertheless, these predefined types are very useful as interfaces between libraries developed independently.

    The predefined library, obviously, uses these types too. These types are predefined in the Standard package:. Packages System and System. Types are organized hierarchically. A type inherits properties from types above it in the hierarchy. Here is a broad overview of each category of types; please follow the links for detailed explanations.

    Inside parenthesis there are equivalences in C and Pascal for readers familiar with those languages. Primitive operations with parameters of specific types are non-dispatching , those with parameters of class-wide types are dispatching. New types can be declared by deriving from specific types; primitive operations are inherited by derivation. You cannot derive from class-wide types. By giving a constraint to an unconstrained subtype, a subtype or object becomes constrained:. Declaring an unconstrained object is only possible if a default value is given in the type declaration above.

    The language does not specify how such objects are allocated. GNAT allocates the maximum size, so that size changes that might occur with discriminant changes present no problem. Another possibility is implicit dynamic allocation on the heap and re-allocation followed by a deallocation when the size changes. Definite subtypes allow the declaration of objects without initial value, since objects of definite subtypes have constraints that are known at creation-time. Object declarations of indefinite subtypes need an initial value to supply a constraint; they are then constrained by the constraint delivered by the initial value.

    Note that unconstrained subtypes are not necessarily indefinite as can be seen above with RD: it is a definite unconstrained subtype. The type system integrates concurrency threading, parallelism. Programmers will use types for expressing the concurrent threads of control of their programs. The core pieces of this part of the type system, the task types and the protected types are explained in greater depth in a section on tasking. Limiting a type means disallowing assignment. Programmers can define their own types to be limited, too, like this:.

    The ellipsis stands for private , or for a record definition, see the corresponding subsection on this page. A limited type also doesn't have an equality operator unless the programmer defines one. You can learn more in the limited types chapter. Formally, the above declaration creates a type and its first subtype named T. The type itself, correctly called the "type of T", is anonymous; the RM refers to it as T in italics , but often speaks sloppily about the type T.

    But this is an academic consideration; for most purposes, it is sufficient to think of T as a type. For scalar types, there is also a base type called T'Base , which encompasses all values of T. For signed integer types, the type of T comprises the complete set of mathematical integers. The base type is a certain hardware type, symmetric around zero except for possibly one extra negative value , encompassing all values of T.

    It is this feature which allows the compiler to detect logic errors at compile time, such as adding a file descriptor to a number of bytes, or a length to a weight. The fact that the two types have the same range does not make them compatible: this is name equivalence in action, as opposed to structural equivalence. Below, we will see how you can convert between incompatible types; there are strict rules for this. You can also create new subtypes of a given type, which will be compatible with each other, like this:.

    It is not necessary that the subtype ranges overlap, or be included in one another. A derived type is a new, full-blown type created from an existing one. Like any other type, it is incompatible with its parent; however, it inherits the primitive operations defined for the parent type.

    Here both types are discrete; it is mandatory that the range of the derived type be included in the range of its parent. Contrast this with subtypes. The reason is that the derived type inherits the primitive operations defined for its parent, and these operations assume the range of the parent type. Here is an illustration of this feature:. Then P is called with the converted parameter. Thus the range check on J 7 in the body of P will pass.

    Ada supports various categories of subtypes which have different abilities. Here is an overview in alphabetical order. A subtype which does not have a name assigned to it. Such a subtype is created with a variable declaration:. In Ada, all types are anonymous and only subtypes may be named. For scalar types, there is a special subtype of the anonymous type, called the base type , which is nameable with the ' Base attribute. The base type comprises all values of the first subtype. Some examples:. The base type Int'Base is a hardware type selected by the compiler that comprises the values of Int.

    Thus it may have the range -2 A subtype of an indefinite subtype that adds constraints. The following example defines a 10 character string sub-type. A definite subtype is a subtype whose size is known at compile-time. All subtypes which are not indefinite subtypes are, by definition, definite subtypes.

    An indefinite subtype is a subtype whose size is not known at compile-time but is dynamically calculated at run-time. An indefinite subtype does not by itself provide enough information to create an object; an additional constraint or explicit initialization expression is necessary in order to calculate the actual size and therefore create the object. X is an object of the indefinite sub type String. Its constraint is derived implicitly from its initial value. X may change its value, but not its bounds. It should be noted that it is not necessary to initialize the object from a literal.

    You can also use a function. A subtype of an indefinite subtype that does not add a constraint only introduces a new name for the original subtype a kind of renaming under a different notion. A subtype which has a name assigned to it. However, if you would like to use this as an index constraint on String , the following declaration is illegal:. This is because String has Positive as its index, which is a subtype of Integer these declarations are taken from package Standard :.

    You see that posing constraints on types versus subtypes has very different effects. Any indefinite type is also an unconstrained subtype. However, unconstrainedness and indefiniteness are not the same. This type is unconstrained and indefinite because you need to give an actual discriminant for object declarations; the object is constrained to this discriminant which may not change. When however a default is provided for the discriminant, the type is definite yet unconstrained; it allows to define both, constrained and unconstrained objects:.

    Here the compiler knows that A is a value of the type Enum. But consider:. The compiler cannot choose between the two versions of P ; both would be equally valid. To remove the ambiguity, you use a qualified expression :. As seen in the following example, this syntax is often used when creating new objects. If you try to compile the example, it will fail with a compilation error since the compiler will determine that is not in range of Byte. Data do not always come in the format you need them. You must, then, face the task of converting them. As a true multi-purpose language with a special emphasis on "mission critical", "system programming" and "safety", Ada has several conversion techniques.

    The most difficult part is choosing the right one, so the following list is sorted in order of utility. You should try the first one first; the last technique is a last resort, to be used if all others fail. There are also a few related techniques that you might choose instead of actually converting the data. Since the most important aspect is not the result of a successful conversion, but how the system will react to an invalid conversion, all examples also demonstrate faulty conversions.

    An explicit type conversion looks much like a function call; it does not use the tick apostrophe, ' like the qualified expression does. The compiler first checks that the conversion is legal, and if it is, it inserts a run-time check at the point of the conversion; hence the name checked conversion. Most compilers are very smart and optimise away the constraint checks; so, you need not worry about any performance penalty.

    Some compilers can also warn that a constraint check will always fail and optimise the check with an unconditional raise. Explicit conversions are possible between any two numeric types: integers, fixed-point and floating-point types.

    Ada Reference Manual info format

    You might ask why you should convert between two subtypes of the same type. An example will illustrate this. Here, Slice has bounds 1 and 10, whereas X The examples above all revolved around conversions between numeric types; it is possible to convert between any two numeric types in this way. But what happens between non-numeric types, e. The answer is two-fold:. Why would you want to derive a record type from another record type? Because of representation clauses. Here we enter the realm of low-level systems programming, which is not for the faint of heart, nor is it useful for desktop applications.

    So hold on tight, and let's dive in. Suppose you have a record type which uses the default, efficient representation. Now you want to write this record to a device, which uses a special record format. This special representation is more compact uses fewer bits , but is grossly inefficient. You want to have a layered programming interface: the upper layer, intended for applications, uses the efficient representation.

    • Ada for Software Engineers - Preface and Table of Contents.
    • Mobility, Sexuality and AIDS (Sexuality, Culture and Health).
    • stl - Algorithms for generic containers in Ada - Stack Overflow.
    • Resources on Ada: Managing Complexity?
    • The 1549 Rebellions and the Making of Early Modern England;
    • Log Reference: Why Ada!
    • The worst mistake of computer science.

    The lower layer is a device driver that accesses the hardware directly and uses the inefficient representation. The compiler chooses a default, efficient representation for Register. For example, on a bit machine, it would probably use three bit words, one for A, one for B and one for Size. This efficient representation is good for applications, but at one point we want to convert the entire record to just 8 bits, because that's what our hardware requires. In the above example, the package body declares a derived type with the inefficient, but compact representation, and converts to and from it.

    Within object-oriented programming you have to distinguish between specific types and class-wide types. With specific types, only conversions in the direction to the root are possible, which of course cannot fail. There are no conversions in the opposite direction where would you get the further components from?

    With the conversion itself, no components of the source object that are not present in the target object are lost, they are just hidden from visibility. Therefore, this kind of conversion is called a view conversion since it provides a view of the source object as an object of the target type especially it does not change the object's tag. It is a common idiom in object oriented programming to rename the result of a view conversion. A renaming declaration does not create a new object; it only gives a new name to something that already exists. All types derived from a tagged type T form a tree rooted at T.

    The class-wide type T'Class can hold any object within this tree. These conversions are also view conversions, no data is created or lost. Both objects are of the class-wide type. Conversions to any type within the given class are legal, but are tag-checked. The second conversion fails the tag check. Conversion assignments of this kind will rarely be used; dispatching will do this automatically, see object oriented programming. Ada's access type is not just a memory location a thin pointer. Depending on implementation and the access type used, the access might keep additional information a fat pointer.

    For example GNAT keeps two memory addresses for each access to an indefinite object — one for the data and one for the constraint informations Size , First , Last. If you want to convert an access to a simple memory location you can use the package System. Note however that an address and a fat pointer cannot be converted reversibly into one another. The address of an array object is the address of its first component.

    Thus the bounds get lost in such a conversion. One of the great criticisms of Pascal was "there is no escape". The reason was that sometimes you have to convert the incompatible. It is your chore to make sure that the requirements on unchecked conversion as stated in RM Use the 'Valid attribute after the conversion to check the validity of the data in problematic cases.

    The compiler may also do a conversion in place every instance has the convention Intrinsic. In the example below, you can see how this is done. No error will be reported, but is this the result you expect? Thus if B were defined as B: Byte range By using overlays, both objects share the same memory location. If you assign a value to one, the other changes as well. The syntax is:. You have to take care also of implicit initializations of objects of the target type, since they would overwrite the actual value of the source object.

    The Import pragma with convention Ada can be used to prevent this, since it avoids the implicit initialization, RM B. Just for the record: There is still another method using the Export and Import pragmas. However, since this method completely undermines Ada's visibility and type concepts even more than overlays, it has no place here in this language introduction and is left to experts.

    T encompasses the complete set of mathematical integers. Static expressions and named numbers make use of this fact. They are converted to the appropriate specific type where needed. Static expressions are evaluated at compile-time on the appropriate types with no overflow checks, i.

    It has the range System. During run-time, computations of course are performed with range checks and overflow checks on the appropriate subtype. Intermediate results may however exceed the range limits. Thus with I, J, K of the subtype T above, the following code will return the correct result:.

    Types can be made from other types. Array types, for example, are made from two types, one for the arrays' index and one for the arrays' components. An array, then, expresses an association, namely that between one value of the index type and a value of the component type. See array. A range is a signed integer value which ranges from a First to a last Last. It is defined as. When declaring a range type, the corresponding mathematical operators are implicitly declared by the language at the same place.

    Unsigned integers in Ada have a value range from 0 to some positive number not necessarily 1 subtracted from some power of 2. They are defined using the mod keyword because they implement a wrap-around arithmetic. Additionally to the normal arithmetic operators, bitwise and , or and xor are defined for the type see below. The predefined package Interfaces RM B.

    The values of n depend on compiler and target architecture. You can use range to sub-range a modular type:. Arithmetic with such a type is interesting to say the least. Be very careful with bitwise operators and , or , xor , not , when the modulus is not a power of two. An example might exemplify the problem. Now take a modulus that is not a power of two. Naive expectations about the results may lead out of the value range. As an example take again the not operator see the RM for the others :.

    The definition of not is therefore:. Like for numeric types, where e. There are no other values assignable to objects of this type. This position can be queried via the 'Pos attribute ; the inverse is 'Val, which returns the corresponding literal. In our example:. There are two other important attributes: Image and Value don't confuse Val with Value. Image returns the string representation of the value in capital letters , Value is the inverse:. Note that, since Ada is case-insensitive, the string given to 'Value can be in any case. Overload resolution within the context of use of a literal normally resolves which Red is meant.

    Only if you have an unresolvable overloading conflict, you can qualify with special syntax which Red is meant:. Like many other declarative items, enumeration literals can be renamed. In fact, such a literal is a actually function , so it has to be renamed as such:. Renaming makes Red directly visible without necessity to resort the use-clause. Every type that has at least one character literal is a character type. Ada's Character type is defined that way. There is special semantics implied with this declaration in that objects and expressions of this type can be used as conditions.

    Note that the literals False and True are not Ada keywords. Thus it is not sufficient to declare a type with these literals and then hope objects of this type can be used like so:. If you need your own Booleans perhaps with special size requirements , you have to derive from the predefined Boolean:. You can use range to subtype an enumeration type:. Enumeration types being scalar subtypes, type attributes such as First and Succ will allow stepping through a subsequence of the values.

    A loop will automatically step through the values of the subtype's range. Filtering week days to include only working days with an even position number:. Wikipedia has related information at Floating point. To define a floating point type, you only have to say how many digits are needed, i. This facility is a great benefit of Ada over most other programming languages. In other languages, you just choose between "float" and "long float", and what most people do is:.

    In Ada, you specify the accuracy you need, and the compiler will choose an appropriate floating point type with at least the accuracy you asked for. This way, your requirement is guaranteed. Moreover, if the computer has more than two floating point types available, the compiler can make use of all of them. Wikipedia has related information at Fixed-point arithmetic. A fixed point type defines a set of values that are evenly spaced with a given absolute precision. In contrast, floating point values are all spaced according to a relative precision.

    The absolute precision is given as the delta of the type. There are two kinds of fixed point types, ordinary and decimal. For Ordinary Fixed Point types, the delta gives a hint to the compiler how to choose the small value if it is not specified: It can be any integer power of two not greater than delta. You may specify the small via an attribute clause to be any value not greater than delta. If the compiler cannot conform to this small value, it has to reject the declaration.