Inferno Programmer's Guide / Руководство программиста по ОС Inferno

→A comma-separated sequence of identifiers is followed by a colon and then the name of a type. Each identifier is declared as having that type and denotes a particular object for the rest of its scope (see Scope). If the declaration contains = and an expression, all the objects are initialized from the value of the expression. In a declaration at the top level (outside a function), the expression must be constant or an array initialized with constant expressions; the bound of any array must be a constant expression. Lists and ref adt types can not be initialized at the top level.
If an object is not explicitly initialized, then it is always set to nil if it has a reference type; if it has arithmetic type, then it is set to 0 at the top level and is undefined if it occurs within a function.
0 Последовательность идентификаторов разделенная запятыми сопровождается двоеточием и затем именем типа. Каждый идентификатор объявлен имеющим этот тип и обозначает определенный объект для оставшейся части его области видимости (смотрите Видимость). Если объявление содержит = и выражение, все объекты инициализированы из значения выражения. В объявлении на верхнем уровне (вне функции), выражение должно быть константой или массивом инициализированным константными выражениями; граница массива должна быть константным выражением.
→These forms constitute the basic way for declaring and initializing data:
identifier-list : type; identifier-list : type = expression;
0 Эти формы составляют основной путь для объявления и инициализации данных:
список-идентификаторов : тип; список идентификаторов : тип = выражение;
→Data Declarations
0 Объявления типов данных
→declaration:
identifier-list : type; identifier-list : type = expression; identifier : = expression; ( id-or-nil-list ) : = expression; identifier-list : con expression; identifier-list : import identifier; identifier-list : type type; include string-constant;
identifier-list: identifier identifier-list, identifier
expression-list: expression expression-list, expression
0 Объявления
список-идентификаторов: тип, список-идентификаторов: тип = оператор, идентификатор = оператор; ( id-or-nil-list ) : = оператор; список-идентификаторов : con expression; список-идентификаторов : import идентификатор; список-идентификаторов : тип тип; include строковая-константа;
список-идентификаторов: идентификатор список-идентификаторов, идентификатор список-выражений: выражение список-выражений, выражение
→Declarations take several forms:
0 Объявления принимают несколько форм:
→Declarations are used both at the top level (outside of functions) and inside functions and module declarations. Some styles of declaration are allowed only in certain of these places, but all will be discussed together.
0 Оба объявления используются на верхнем уровне(вне функций) и внутри функций и объявлений модулей. Некоторый стили объявлений разрешены только точно на каком-то из этих месте, но обсуждены они будут вместе.
→The i mpl ement declaration at the start identifies the type of the module that is being implemented. The rest of the program consists of a sequence of various kinds of declarations and definitions that announces the names of data objects, constants, types, and functions, and it creates and initializes the declarations and definitions. It must include a module declaration for the module being implemented and the objects it announces. It can include declarations for the functions, data objects, types, and constants used privately within the module, as well as declarations for modules used by it.
0 Объявление ввода в программу в начале идентифицирует тип модуля который в нее вводится. В остальном коде программы находится последовательность различных типов объявлении и определений, которые анонсируют имена объектов данных, констант, типов и функции и они создают и инициализируют объявления и определения. Они должны включать объявления модулей для модулей, которые вводятся в код программы и объектов, которые они анонсируют.
→At the top level, a program consists of a sequence of declarations. The syntax is:
program:
implement identifier ; top-declaration-sequence
top-declaration-sequence: top-declaration top-declaration-sequence top-declaration
top-declaration: declaration
identifier-list : = expression; identifier-list = expression; ( identifier-list ) : = expression; module-declaration function-definition adt-declaration
0 На верхнем уровне, в программе есть последовательность объявлений. Синтаксис таков:
программа:
implement identifier ; top-declaration-sequence
top-declaration-sequence: top-declaration top-declaration-sequence top-declaration
top-declaration: declaration
identifier-list : = expression; identifier-list = expression; ( identifier-list ) : = expression; module-declaration function-definition adt-declaration
→Top Level
0 Верхний уровень
→Other files, conventionally named with the suffix . m, contain declarations for things obtainable from other modules. These files are incorporated by an i ncl ude declaration in the implementation modules that need them.
0 Другие файлы, имя которых по соглашению заканчивается суффиксом .m, содержат объявления для тех вещей, которые доступны из других модулей. Эти файлы объедены директивой include в подключаемых модулях, которые нужны ему.
→Limbo source programs that implement modules are stored in files, conventionally named with the suffix . b. Each source file begins with a single i mpl ement directive naming the type of the module, followed by a sequence of declarations.
0 Исходный код программ на Limbo, в которым подключаемые модули хранятся в файлах, по соглашению заканчивается суффиксом .b. Каждый исходный файл, начинающийся директивы подключения имен модуля типа, продолжается последовательностью объявлений.
→This means that the first argument of pri nt is a string and that other arguments can be given when the function is called. The Limbo language itself has no way of accessing these arguments; the notation is an artifice for describing facilities built into the runtime system, such as the Sys module.
0 Это означает, что первый аргумент функции print - строка и остальные могут быть переданы, когда функция вызывается. Сам по себе язык Limbo не имеет доступа к этим аргументам, используется искусственное обозначение для описания конструкций встроенных в runtime-систему поддержки исполнения программ, такую как модуль Sys.
→The star character * can be given as the last argument in a function type. It declares that the function is variadic; during a call, actual arguments at its position and following are passed in a manner unspecified by the language. For example, the type of the pri nt function of the Sys module is:
fn (s : string, *) : int
0 Символ звездочка * может передаваться как последний аргумент в типе функции.
Он объявляет, что функция с переменным числом аргументов, во время вызова, текущий аргумент на его позиции и последующий передаются неопределенным для языка образом. Например, тип функции print модуля Sys такой:
fn (s : string, *) : int
→The following is an example of a function that takes a string argument and returns no value:
fn (nil : string)
The self keyword has a specialized use within adt declarations. It can be used only for the first argument of a function declared within an adt; its meaning is discussed in the ADT Declarations section.
0 В следующий пример иллюстрирует пример функции, который берет аргумент строки и не возвращает никакого значения:
fn (nil : string)
Ключевое слово self имеет специализированную область использования внутри объявления adt. Она может быть использована толко для первого аргумента функции объявленной внутри adt, ее значение обсуждается в секции "Объявления ADT".
→The denotation of a function type has the keyword f n followed by a comma-separated list of its arguments enclosed in parentheses, and perhaps followed by the type the function returns. Absence of a return value means that the function returns no value; it is a procedure. The names and types of arguments are specified. However, the name of an argument can be replaced by ni 1, making it nameless. For example:
fn (nil : int, nil : int) : int
fn (radius : int, angle : int) : int
fn (radius, angle : int) : int
all denote exactly the same type, namely a function of two integers that returns an integer.
0 У обозначения типа функции есть ключевое слово fn, следующее за разделенным запятыми списком его аргументом, заключенных в скобки и, возможно, сопровождающееся типом значения, которое функция возвращает. Отсутствие возвращаемого значения означает, что функция его не возвращает - она является процедурой. Имена и типы аргументов определяются. Однако, имя аргумента заменяется на nil, делая его безымянным. Например:
fn (nil : int, nil : int) : int
fn (radius : int, angle : int) : int
fn (radius, angle : int) : int
все они обозначают в точности один и тот же тип, функция с двумя целыми значениями, которая возвращает целое.
→A function type characterizes the arguments and return value of a function. The syntax is:
function-type:
f n function-arg-ret
function-arg-ret:
(formal-arg-listopt^) (formal-arg-list ^) : data-type
formal-arg-list: formal-arg formal-arg-list, formal-arg
formal-arg:
nil-or-D-list : type
nil-or-D-list : self ref t identifier
nil-or-D-list: nil-or-D nil-or-D, nil-or-D
nil-or-D:
identifier nil
0 Тип функции характерезует передаваемыми ей аргументами и возвращаемым значением. Синтаксис таков:
тип-функции:
fn возвращаемые-аргументы-функции
возвращаемые-аргументы-функции:
(опциисписка-формал-арг^)(список-формал-арг^):тип-данных
список-формал-арг: формал-арг список-формал-арг,формал-арг
формал-арг:
nil-или-D-list : тип
nil-или-D-список : self ref t идентификатор
nil-или-D-список: nil-или-D nil-или-D, nil-или-D
nil-или-D:
идентификатор nil
→There is also a ref adt type representing a reference (pointer) to an adt. It is denoted:
ref adt-type
where the identifier is the name of an adt type.
Once an adt has been declared, the identifier associated with it becomes a data-type name.
0 Здесь модуль ref adt предостовляется как ссылка на объект(указатель) типа adt. Он обозначает:
ref тип-adt
Где идентификатор - это имя типа adt.
Тогда, когда объявлен, идентификатор ассоциированный с ним становится именем типа-данных.
→An abstract data type or adt is an object that can contain data objects of several different types and can declare functions that operate on them. An adt is denoted:
adt-type:
module-qualified-type identifier
0 Абстрактный тип данных или adt - это объект, который может содержать объекты данных нескольких разных типов и объявление функции, которые работают ими. Абстрактный тип данных обозначает:
тип-adt:
модулем-квалифицированый-тип идентификатор
→When a type is declared within a module declaration, the name of that type is not generally visible to the rest of the program unless a specific i mpo r t request is given (see Declarations with Import and Referring to Modules). Without such a request, when objects of that type are declared in a client module, the type name is qualified.
module-qualified-type:
identifier -> identifier
Here the first identifier is either the name of a module or a variable of the module type. The second is the name of a type in the module's declaration.
0 Когда тип объявили внутри модули объявления модуля, его название в основном не видно для большинства программ, до тех пор пока не дано специальное слово import(смотрите разделы Объявления с импортированием и Ссылки на модуля ).
Без такого запроса, когда объекты типа объявлены в модуле клиента, название типа квалифировано.
Модуль - имя типа квалифицировано
квалифицированный-модулем-тип:
идентификатор -> идентификатор
Здесь должен быть идентификатор - либо название модуля, либо переменной типа модуля. Второй - это название типа в объявлении модуля.
→Module-qualified type
0 Тип квалифицированный модулем
Резюме
Пол:
мужчина
Родной язык:
русский
С нами:
с 17 марта 2009 г. (6424 дня)
Деятельность:
3282 версии перевода с общим рейтингом 172
325 комментариев
Карма: 13 (оценок: 13)
Написать wuffur личное сообщение