Changes between Version 11 and Version 12 of Fundamentals
- Timestamp:
- 05/13/23 13:09:22 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Fundamentals
v11 v12 1 = CIVL-C Language 1 2 2 = Overview of CIVL-C3 == Overview of CIVL-C 3 4 4 == Main Concepts5 === Main Concepts 5 6 6 7 CIVL-C is an extension of a subset of Standard C. It includes the most commonly-used elements of C, including most of the syntax, types, expressions, and statements. Missing are some of the more esoteric type qualifiers, bitwise operations (at least for now), and much of the standard library. Moreover, none of the C language elements dealing with concurrency are included, as CIVL-C has its own concurrency primitives. … … 14 15 Scopes and processes are the two central themes of CIVL-C. Each has a static and a dynamic aspect. The static scopes correspond to the lexical scopes in the program—typically, regions de- limited by curly braces `{`. . . `}`. At runtime, these scopes are instantiated when control in a process reaches the beginning of the scope. Processes are created dynamically by spawning functions; hence the functions are the static representation of processes. 15 16 16 == Example Illustrating Scopes and Processes17 === Example Illustrating Scopes and Processes 17 18 18 19 To understand the static and dynamic nature of scopes and processes, and the relations between them, we consider the (artificial) example code in Fig. 1(a). The static scopes in the code are numbered from 0 to 6. … … 43 44 * Processes are created when functions are spawned; they disappear from the state when their stack becomes empty (either because the process terminates normally or invokes the exit system function). 44 45 45 == Structure of a CIVL-C program46 === Structure of a CIVL-C program 46 47 47 48 A CIVL-C program is structured very much like a standard C program. In particular, a CIVL- C program may use the preprocessor directives specified in the C Standard, and with the same meaning. A source program is preprocessed, then parsed, resulting in a translation unit, just as with standard C. The main differences are the nesting of function definitions and the new primitives beginning with `$`, which are described in detail in the remainder of this part of the manual. … … 55 56 As usual, a translation unit consists of a sequence of variable declarations, function prototypes, and function definitions in file scope. In addition, assume statements may occur in the file scope. These are used to state assumptions on the input values to a program. 56 57 57 = Sequential Elements58 == Sequential Elements 58 59 59 60 In this chapter we describe the main sequential elements of the language. For the most part these are the same as in C. Primitives dealing with concurrency are introduced in the next chapter. 60 61 61 == Types62 === Types 62 63 63 === Standard types inherited from C64 ==== Standard types inherited from C 64 65 65 66 The `civlc.cvh` defines standard types inherited from C. The boolean type is denoted `_Bool`, as in C. Its values are 0 and 1, which are also denoted by `$false` and `$true`, respectively. … … 71 72 Array types, `struct` and `union` types, `char`, and pointer types (including pointers to functions) are all exactly as in C. 72 73 73 === The bundle type: `$bundle`74 ==== The bundle type: `$bundle` 74 75 75 76 CIVL-C includes a type named `$bundle`, declared in the CIVL-C standard header `bundle.cvh`. A bundle is basically a sequence of data, wrapped into an atomic package. A bundle is created using a function that specifies a region of memory. One can create a bundle from an array of integers, and another bundle from an array of reals. Both bundles have the same type, `$bundle`. They can therefore be entered into an array of `$bundle`, for example. Hence bundles are useful for mixing objects of different (even statically unknown) types into a single data structure. Later, the contents of a bundle can be extracted with another function that specifies a region of memory into which to unpack the bundle; if that memory does not have the right type to receive the contents of the bundle, a runtime error is generated. The bundle type and its functions are provided by the library `bundle.cvh`. 76 77 The relevant functions for creating and manipulating bundles are given in ... 77 78 78 === The `$scope` type79 ==== The `$scope` type 79 80 80 81 An object of type `$scope` is a reference to a dynamic scope. It may be thought of as a “dynamic 81 82 scope ID, ” but it is not an integer and cannot be converted to an integer. Operations defined on scopes are discussed in Section .... 82 83 83 === The `$range` and `$domain` types84 ==== The `$range` and `$domain` types 84 85 85 86 CIVL-C provides certain abstract datatypes that are useful for representing iteration spaces of loops in an abstract way.
