Here, we present the Slice language. Slice (Specification Language for Ice) is the fundamental abstraction mechanism for separating object interfaces from their implementations. Slice establishes a contract between client and server that describes the types and object interfaces used by an application. This description is independent of the implementation language, so it does not matter whether the client is written in the same language as the server.
在这一章我们将介绍Slice语言 Slice (Specification Language for Ice)是一种用于使对象接口与其实现相分离的基础性抽象机制。Slice在客户与服务器之间建立合约,描述应用所使用的各种类型及对象接口。这种描述与实现语言无关,所以编写客户所用的语言是否与编写服务器所用的语言相同,这没有什么关系。
Slice definitions are compiled for a particular implementation language by a compiler. The compiler translates the language-independent definitions into language-specific type definitions and APIs. These types and APIs are used by the developer to provide application functionality and to interact with Ice. The translation algorithms for various implementation languages are known as language mappings. Currently, Ice defines language mappings for C++, Java, C#, Python, Objective-C, Ruby, and PHP.
Slice定义由编译器编译到特定的实现语言 。编译器把与语言无关的定义翻译成针对特定语言的类型定义和API。开发者使用这些类型和API来提供应用功能,并与Ice交互。用于各种实现语言的翻译算法称为语言映射(language mappings)。Ice目前定义了C++, Java, C#, Python, Objective-C, Ruby, 和PHP的语言映射。
Because Slice describes interfaces and types (but not implementations), it is a purely declarative language; there is no way to write executable statements in Slice.
因为Slice描述的是接口和类型 (不是实现),它是一种纯粹的描述性语言;你无法用Slice编写可执行语句。
Slice definitions focus on object interfaces, the operations supported by those interfaces, and exceptions that may be raised by operations. In addition, Slice offers features forobject persistence. This requires quite a bit of supporting machinery; in particular, much of Slice is concerned with the definition of data types. This is because data can be exchanged between client and server only if their types are defined in Slice. You cannot exchange arbitrary C++ data between client and server because it would destroy the language independence of Ice. However, you can always create a Slice type definition that corresponds to the C++ data you want to send, and then you can transmit the Slice type.
Slice定义关注的焦点是对象接口、这些接口所支持的操作,以及操作可能引发的异常。此外,Slice还提供了一些用于对象持久的特性 (参见第21章)。这需要相当多的支持机制;特别地,Slice的相当一部分关注的是数据类型的定义。这是因为,只有在其类型用Slice进行了定义之后,数据才能在客户与服务器之间交换。你不能在客户与服务器之间交换任意的C++数据,因为 这可能会摧毁Ice的语言无关性。但是,你总能创建一种Slice类型定义,与你想要发送的C++数据相对应,然后你就可以传送这种Slice类型了。
We present the full syntax and semantics of Slice here. Because much of Slice is based on C++ and Java, we focus on those areas where Slice differs from C++ or Java or constrains the equivalent C++ or Java feature in some way. Slice features that are identical to C++ and Java are mentioned mostly by example.
在此我们将介绍Slice的完整语法和语义。因为Slice的许多语法和语义都是以C++和Java为基础的,我们将特别关注Slice与C++或Java不同的部分,或是Slice以某种方式限制了等价的C++或Java特性的部分。与C++和Java特性相同的Slice特性通常会用例子来说明。