【Ada语言学习笔记】参考手册中文翻译及注记——语言概述

我们在Concurrent & Distributed Systems课的实验中需要用到Ada语言。

通俗而笼统地讲,Ada语言是一种描述特别详尽的语言(highly specific),因此它的特点是在编译阶段和运行时能够进行大量的检查,能够更加精确地定位错误的位置和类型(因为语言本身详尽了,你提供的信息量越大,编译器能够做的就更多)。

这里是Ada的参考手册

本篇翻译手册中的语言概述(Language Summary)。

http://blog.csdn.net/iyundi

Language Summary

11

An Ada program is composed of one or more program units. Program units may be subprograms (which define executable algorithms), packages (which define collections of entities), task units (which define concurrent computations), protected units (which define
operations for the coordinated sharing of data between tasks), or generic units (which define parameterized forms of packages and subprograms). Each program unit normally consists of two parts: a specification, containing the information that must be visible
to other units, and a body, containing the implementation details, which need not be visible to other units. Most program units can be compiled separately.

Ada程序由一到多个程序单元组成。程序单元可以是子程序(定义可执行的算法)、(定义实体的集合)、任务单元(定义并行计算单元)、受保护单元(定义针对任务间协作的共享数据的操作)或泛型单元(定义参数化的包和子程序)。每个程序单元通常由两部分组成:定义段(specification)——包含应对其他单元可见的信息,和主体段(body)——包含实现的细节,不需被其他单元所见。大多数程序单元可以被独立地编译。

注:在实验指导里还有一句:In Ada those two aspects are separated into two separate source files which will be independently compiled. 这两部分分别位于两个独立的原文件中并将会被独立地编译。

12

This distinction of the specification and body, and the ability to compile units separately, allows a program to be designed, written, and tested as a set of largely independent software components.

定义段与实体段的分离,以及不同单元分开编译的能力,使得一个程序可以作为一组高度独立的软件组件而被设计、编写和测试。

13

An Ada program will normally make use of a library of program units of general utility. The language provides means whereby individual organizations can construct their own libraries. All libraries are structured in a hierarchical manner; this enables the logical
decomposition of a subsystem into individual components. The text of a separately compiled program unit must name the library units it requires.

Ada程序通常会利用作为通用工具的程序单元库。这一语言提供了一些方法,使得不同的组织可以构建自己的库。所有的库以层次结构来组织:这样就能够将一个子系统从逻辑上分解为独立的组件。分别独立编译的程序单元文本必须指明它所需库单元的名字。

14

Program Units

程序单元

15

A subprogram is the basic unit for expressing an algorithm. There are two 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
have 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 will return a result.

子程序表达算法的基本单元。有两种子程序:过程(procedure)和函数(function)。过程就是调用一系列的动作。例如读取数据、更新变量、产生输出。它可以有形参,以一种受控的方式在调用点和过程(procedure)间传递信息。函数则是调用一个计算过程来得到一个值。它很像过程,但额外返回一个结果。

16

A package is the basic unit for defining a collection of logically related entities. For example, a package can be used to define a set of type declarations and associated operations. Portions of a package can be hidden from the user, thus allowing access only
to the logical properties expressed by the package specification.

(package)是定义逻辑上相互关联的一组实体的基本单元。例如,包可以用来定义一组(数据)类型声明以及(对这些数据的)相关操作。包的一些部分可以对用户透明,这样就只允许对包的定义段所表达的逻辑属性进行访问。

17

Subprogram and package units may be compiled separately and arranged in hierarchies of parent and child units giving fine control over visibility of the logical properties and their detailed implementation.

子程序和包可以被分别编译,并以父子单元的层次结构组织,以实现逻辑属性和实现细节(二者)的可见性的精确控制。

:子程序和包都是程序单元,二者在概念上是并列关系。

18

A task unit is the basic unit for defining a task whose sequence of actions may be executed concurrently with those of other tasks. Such tasks may be implemented on multicomputers, multiprocessors, or with interleaved execution on 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 tasks.

任务单元是定义任务的基本单元(废话……)。任务由一系列操作(actions)组成,这一系列操作可以和其他任务的操作序列并行地执行。

19/2

A protected unit is the basic unit for defining protected operations for the coordinated use of data shared between tasks. Simple mutual exclusion is provided automatically, and more elaborate sharing protocols can be defined. A protected operation can either
be a subprogram or an entry. A protected entry specifies a Boolean expression (an entry barrier) that must be True before the body of the entry is executed. A protected unit may define a single protected object or a protected type permitting the creation of
several similar objects.

受保护单元是定义对协作的任务之间的共享数据的操作的基本单元。可以自动实现简单的互斥,且用户可以自己定义更为复杂精细的共享协议。受保护操作可以是子程序,也可以是一个项(entry)。受保护项特别定义了(specifies)一个布尔表达式(an entry barrier: 项的壁垒/守卫):只有该表达式为真,项的主体才能被执行。受保护单元可以定义单一的受保护对象,也可以定义一个受保护类型,允许程序员创建一类相似的对象。

20

Declarations and Statements

声明语句和执行语句

21

The body of a program unit generally contains two parts: a declarative part, which defines the logical entities to be used in the program unit, and a sequence of statements, which defines the execution of the program unit.

程序单元的主体段通常包含两部分:声明部分——定义了程序单元中将要用到的逻辑实体;执行语句序列——定义了程序单元的执行。

注:程序单元=声明段+主体段,主体段=声明语句部分+执行语句部分。

——22

The declarative part associates names with declared entities. For example, a name may 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
units, and generic units to be used in the program unit.

声明语句部分将名称和被声明的实体相关联。例如,一个名称可能代表一个类型、一个常量、一个变量或者一个异常。声明语句部分也引入被该程序单元所使用的其他嵌套的子程序、包、任务单元、受保护单元和泛型单元的名称和形参。

23

The sequence of statements describes a sequence of actions that are to be performed. The statements are executed in succession (unless a transfer of control causes execution to continue from another place).

执行语句序列描述了应被执行的操作序列。语句是顺序执行的(除非有控制转移语句使得程序跳转到另一个位置继续执行)。

24

An 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 corresponding formal parameters.

赋值语句改变变量的值。过程调用先将调用处传入的实参与对应的形参相联系,再触发过程的执行。

25

Case statements and if statements allow the selection of an enclosed sequence of statements based on the value of an expression or on the value of a condition.

case语句和if语句表达基于表达式或条件的值的一种选择,每条选择的后面跟有应执行的语句序列。

26

The loop statement provides the basic iterative mechanism in the language. A loop statement specifies that a sequence of statements is to be executed repeatedly as directed by an iteration scheme, or until an exit statement is encountered.

loop语句提供基本的迭代机制。loop语句表示将一系列语句重复执行,或按照一定的迭代规则、或执行直到遇到exit语句。

27

A block statement comprises a sequence of statements preceded by the declaration of local entities used by the statements.

block语句包含了一系列语句,它紧跟着它将要使用的局部实体声明部分。

28

Certain statements are associated with concurrent execution. 某些语句和并发执行有关。

A delay statement delays the execution of a task for a specified duration or until a specified time.

delay语句延迟一个task的执行,或是延迟一段规定的时间、或是延迟直到某个特定时刻。

An entry call statement is written as a procedure call statement; it requests an operation on a task or on a protected object, blocking the caller until the operation can be performed. A called task may accept an entry call by executing a corresponding accept
statement, which specifies the actions then to be performed as part of the rendezvous with the calling task. An entry call on a protected object is processed when the corresponding entry barrier evaluates to true, whereupon the body of the entry is executed.

entry call语句像过程调用语句一样书写;它请求一个任务或受保护对象的操作,阻塞调用者直到操作可以被执行。被调用的任务可以用执行对应的accept语句的方式接受一个entry call,……

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 response to some triggering event.

……

29

Execution of a program unit may encounter error situations in which normal program execution cannot continue. For example, an arithmetic computation may exceed the maximum allowed value of a number, or an attempt may be made to access an array component by
using an incorrect index value. To deal with such error situations, the statements of a program unit can be textually followed by exception handlers that specify the actions to be taken when the error situation arises. Exceptions can be raised explicitly by
a raise statement.

程序单元的执行可能遇到错误,导致程序的正常执行不能继续。例如,代数计算的结果可能超过最大表示范围,或者数组越界。为了处理这些错误情况,程序单元的语句之后可以直接跟着异常处理语句(exception handlers),用来定义错误出现时应执行的操作。异常可由显式的raise语句抛出。

30

Data Types

数据类型

31

Every object in the language has a type, which characterizes a set of values and a set of applicable operations. The main classes of types are elementary types (comprising enumeration, numeric, and access types) and composite types (including array and record
types).

每个对象都有类型,类型刻画了一系列取值和一组合法操作。类型主要分为两类:基本类型(包括枚举类型enumeration,数值类型numeric,和一些访问类型access types)和组合类型(包括数组和记录(结构体))。

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.

枚举类型定义了互异的枚举文字的有序集合,比如状态的列表或字符的字母表。预定义的枚举类型有布尔型Boolean,字符型Character,宽字符型Wide_Character,和宽宽字符型Wide_Wide_Character。orz

33

Numeric types provide a means of performing exact or approximate numerical computations. 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.

数值类型可用于开展精确或近似的数值计算。精确计算使用整型(integer),定义一组连续的整数。近似计算或使用定点小数类型(定义误差的绝对范围),或使用浮点小数类型(定义误差的相对范围)。预定义的数值类型有整型Integer,浮点型Float和Duration型。

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 an object with indexed components of the same type. A record is an object with named components of
possibly different types. Task and protected types are also forms of composite types. The array types String, Wide_String, and Wide_Wide_String are predefined.

复合类型允许定义由相关组件构成的有结构的对象。复合类型包括数组和结构体。数组是同一类型数据的有序序列的整体,其中每个元素对应一个索引index。结构体由可能不同类型的被命名成员组成的整体。任务类型和受保护类型也是复合类型。预定义的类型有字符串,宽字符串和宽宽字符串……

35

Record, task, and protected types may have 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.

结构体、任务和受保护类型可能有特殊的成员,叫做判别式,它使其所属类型参数化。根据结构体类型内部的定义,结构体的组成可以根据判别式的值而变。

36

Access types allow the construction of linked data structures. A value of an access type represents a reference to an object declared as aliased or to an object created by the evaluation of an allocator. Several variables of an access type may 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 be altered during program execution. Access types also permit references to subprograms
to be stored, passed as parameters, and ultimately dereferenced as part of an indirect call.

访问类型允许建立链式数据结构(类似于指针,所谓“访问”……)。指针类型的值表示对一个定义为“有别称”的对象的引用,或者表示一个由分配器求值而得到的对象。指针类型的几个不同变量可以指向同一个对象,一个对象的成员可以指向同一个或其他对象。在这种链式数据结构中的两个元素和它们的关系都可以在运行时改变。指针类型也允许对子程序的引用,对其进行存储、作为参数传递以及最终作为间接调用的一部分解引用。

37

Private types permit restricted views of a type. A private type can be defined in a package so that only the logically necessary properties are made visible to the users of the type. The full structural details that are externally irrelevant are then only available
within the package and any child units.

私有类型允许限制对一个类型的查看。私有类型可在一个包内定义,只有逻辑上必需的属性才被设为对用户可见。和外界无关的完整的结构细节只有在包内及其子类可见。

38

From any type a new type may be defined by derivation. A type, together with its derivatives (both direct and indirect) form a derivation class. Class-wide operations may be defined that accept as a parameter an operand of any type in a derivation class. For
record and private types, the derivatives may be extensions of the parent type. Types that support these object-oriented capabilities of class-wide operations and type extension must be tagged, so that the specific type of an operand within a derivation class
can be identified at run time. When an operation of a tagged type is applied to an operand whose specific type is not known until run time, implicit dispatching is performed based on the tag of the operand.

任何一个新类型都必须定义为其他类型的继承。一个类型和它的继承者们(包括直接的和间接的)组成了一个继承类。类级的操作可以被定义为用参数接收该类任一类型作为操作数的操作符。对于结构体和私有类型,继承者可以是父类的扩展。支持OO性能的类间操作和类型扩展的那些类型必须做标记,这样才能使某个运算符的在继承类中的每一特定类型在运行时可以被识别。当被标记类型的操作被应用在一个对应操作数的具体类型直到运行时才可知的运算符上之时,基于他们的标签的隐式分配将会被执行。

38.1/2

Interface types provide abstract models from which other interfaces and types may be composed and derived. This provides a reliable form of multiple inheritance. Interface types may also be implemented by task types and protected types thereby enabling concurrent
programming and inheritance to be merged.

接口类型提供抽象的模型,使用它,其他的接口或类型可以被组建或导出。接口类型提供了一种可靠的多重继承的形式。接口类型也可以应用于任务类型和受保护类型,以实现并行程序和将被合并的继承。

39

The concept of a type is further refined by the concept of a subtype, whereby a user can constrain the set of allowed values of a type. Subtypes can be used to define subranges of scalar types, arrays with a limited set of index values, and records and private
types with particular discriminant values.

类型的概念可以进一步地用子类型(subtype)来细化定义,在那里,用户可以限定类型的一组允许的取值。子类型可以被用于定义标量的子范围,数组下标的子区间,和结构体、私有类型的判别式的特定值。

40

Other Facilities

其他工具

41/2

Aspect clauses can be used to specify the mapping between types and features of an underlying machine. For example, the user can specify that objects of a given type must be represented with a given number of bits, or that the components of a record are to
be represented using a given storage layout. Other features allow the controlled use of low level, nonportable, or implementation-dependent aspects, including the direct insertion of machine code.

……

42/2

The predefined environment of the language provides for input-output and other capabilities by means of standard 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 are also provided.

IO包含在标准库包中,支持用户类型及预定义类型。……

42.1/2

The predefined standard library packages provide facilities such as string manipulation, containers of various kinds (vectors, lists, maps, etc.), mathematical functions, random number generation, and access to the execution environment.

字符串操作、容器(向量、链表、映射等)、数学方程、随机数生成器和运行时环境的访问也包含在标准库包中。

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 systems.

43

Finally, 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 allow general algorithms and data structures to
be defined that are applicable to all types of a given class.

支持泛型。……

(待续)

另附非常好的一个资源:http://wenku.baidu.com/view/d7e075c68bd63186bcebbc2c.html?re=view

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-11-10 11:36:38

【Ada语言学习笔记】参考手册中文翻译及注记——语言概述的相关文章

go语言学习笔记

go语言学习笔记 go语言学习笔记(初级) 最近一直在学习go语言,因此打算学习的时候能够记录 一下笔记.我这个人之前是从来没有记录笔记的习惯, 一直以来都是靠强大的记忆力去把一些要点记住. 读书的时候因为一直都是有一个很安静和很专心的环境, 因此很多事情都能记得很清楚,思考的很透彻.但是随着 年纪不断增加,也算是经历了很多的事情,加上工作有时会让人 特别烦闷,很难把心好好静下来去学习,去思考大自然的终极 奥秘,因此需要记录一些东西,这些东西一方面可以作为一种自我激励 的机制,另一方面,也算是自

Haskell语言学习笔记(64)Lens(4)

Prisms data NewTask = SimpleTask String | HarderTask String Int | CompoundTask String [NewTask] deriving (Show) makePrisms ''NewTask *Main> a ^? _SimpleTask Just "Clean" *Main> b ^? _HarderTask Just ("Clean Kitchen",15) *Main>

Perl语言学习笔记 9 正则表达式处理文本

1.替换 s/PATTERN/REPLACE/; #返回是否替换成功的布尔值 可以使用捕获变量,如:s/(\w)/$1/ 匹配失败则不做任何处理 2.定界符 对于没有左右之分的定界符,重复三次即可,如:s///.s### 对于有左右之分的定界符,需使用两对,一对包含模式,一对包含替换字符串,这两对可以不一样,如:s{}{}.s[]{}.s<>[] 3.可选修饰符 /g可进行全局替换,替换所有匹配到的字符串,如:s/ / /g /s:使得 . 匹配所有字符 /i:大小写无关 4.绑定操作符 $f

Perl语言学习笔记 6 哈希

1.哈希的键是唯一的,值可以重复! 2.访问哈希元素 $hashname{"$key"};#哈希为大括号,数组为方括号,键为字符串 $family_name{"fred"} = "firstd";#给哈希元素赋值 3.哈希键支持任意表达式 $foo = "na"; $family_name{$foo."me"};#获取$family_name{"name"}对应的值 4.访问整个哈希 %

JavaScript--基于对象的脚本语言学习笔记(二)

第二部分:DOM编程 1.文档象模型(DOM)提供了访问结构化文档的一种方式,很多语言自己的DOM解析器. DOM解析器就是完成结构化文档和DOM树之间的转换关系. DOM解析器解析结构化文档:将磁盘上的结构化文档转换成内存中的DOM树 从DOM树输出结构化文档:将内存中的DOM树转换成磁盘上的结构化文档 2.DOM模型扩展了HTML元素,为几乎所有的HTML元素都新增了innerHTML属性,该属性代表该元素的"内容",即返回的某个元素的开始标签.结束标签之间的字符串内容(不包含其它

R语言学习笔记2——绘图

R语言提供了非常强大的图形绘制功能.下面来看一个例子: > dose <- c(20, 30, 40, 45, 60)> drugA <- c(16, 20, 27, 40, 60)> drugB <- c(15, 18, 25, 31, 40) > plot(dose, drugA, type="b") > plot(dose, drugB, type="b") 该例中,我们引入了R语言中第一个绘图函数plot.pl

Go语言学习笔记(一) : 搭建Windows下的Go开发环境

最近突然对Go语言产生了兴趣,主要是因为在使用python的时候遇到了一些不爽的问题,然后发现了Go.Go是Google出的一个动态语言,语法和C++接近,性能也非常的好,而且还支持编译成exe发布,并且不依赖任何虚拟机(其实是打包在exe里面了),这种好语言怎么能够错过?所以便一时兴起,开始学习了起来.由于本人还处于异常小白的阶段,所以文章中可能不免有些错误,欢迎大家各种指正. 安装Go 前往Go语言的官方网站:http://golang.org/, 下载对应平台的安装包.如果是x86的系统可

Perl语言学习笔记 15 智能匹配与give-when结构

1.智能匹配操作符 替代绑定操作符: 在哈希中查找某一个键: 比较两个数组是否完全相同: 查找列表中是否存在某个元素: 智能匹配操作符与顺序无关,~~ 左右元素可以互换 2.智能操作符优先级 3.given语句 相当于c语言的switch语句 4.given可以测试多个条件,在default前用break,否则会导致default一直执行 5.笨拙匹配(正则表达式方式) 6.多个项目的when匹配 可以在语句中间加上其他语句: Perl语言学习笔记 15 智能匹配与give-when结构,布布扣

R语言学习笔记

參考:W.N. Venables, D.M. Smith and the R DCT: Introduction to R -- Notes on R: A Programming Environment for Data Analysis and Graphics,2003. http://bayes.math.montana.edu/Rweb/Rnotes/R.html 前言:关于R 在R的官方教程里是这么给R下注解的:一个数据分析和图形显示的程序设计环境(A system for data