Changes between Version 64 and Version 65 of IR2


Ignore:
Timestamp:
05/03/21 10:18:08 (5 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR2

    v64 v65  
    154154=== Notes ===
    155155
    156 * Sequences, sets, maps, and relations are immutable.   An assignment using objects of this type creates a new copy of the object, just as with primitive types like `int`.
    157 * The main difference between the array type and the sequence type is that elements of an array are addressable, i.e., one can form a pointer such as `&a[i]`.  This is not possible with sequences, sets, maps, or relations---there is no way to have a pointer to any component of such a type.
     156* Sequences, sets, maps, relations, and `$mem` objects are immutable.   An assignment using objects of this type creates a new copy of the object, just as with primitive types like `$int`.
     157* Arrays are similar to sequences.   The main differences are as follows:
     158  * An object (i.e., a variable or component of an object) of array type is initialized once, then will never be assigned to again.   Hence there cannot be a statement of the form `a=...` where `a` has array type.
     159  * After initialization, an object or array type can appear only as the first (left) argument to the subscript operator `[]` or as the argument to the `$length` operator.
     160  * Arrays are mutable.   As in C, the left hand size of an assignment may have the form `a[i]`, where `a` is an object of array type.  Sequences are immutable.
     161  * Elements of an array are addressable, i.e., one can form a pointer such as `&a[i]`.  This is not possible with sequences, sets, maps, or relations---there is no way to have a pointer to any component of such a type.
     162  * A function may neither consume nor return an object of array type.  There is no such restriction for sequences. 
    158163* The difference between the function type and map type: a function is really a procedure in the language, so it can modify the state as well as return a value.    This is like the C notion of "function".   A map is a logical partial function: it is defined on some subset of the domain type, it will always "return" the same value on a given input, and reading it cannot modify the state.
    159164
     
    240245=== `civlc.cvh` ===
    241246
     247Work in progress...
     248
    242249* `round(e,t)`: returns value in numerical type `t` that is "closest" to the given value `e`
    243250 * add argument for rounding mode?
     
    255262 * exceptions may be thrown if evaluating any of the delayed operations results in an exception
    256263
    257 
    258 
    259264{{{
    260265
     
    262267
    263268=== `mem.cvh` ===
     269
     270Work in progress...
    264271
    265272* `mem_reach(ptr)`, where `ptr` is an expression with a pointer type.
     
    278285<T> $int $seq_length( $seq<T> a ); // length of a
    279286<T> T $seq_get( $seq<T> a, $int i ); // get element i of a
    280 <T> $seq<T> $seq_set( $seq<T> a, $int i, T x ); // seq obtained by replacing element i of a with x
    281 <T> $seq<T> $seq_subseq( $seq<T> a, $int start, $int stop ); // subsequence from start to stop-1
    282 <T> $seq<T> $seq_add( $seq<T> a, T e ); // sequence obtained by adding element e to the end of a
    283 <T> $seq<T> $seq_append( $seq<T> a1, $seq<T> a2 ); //  sequence obtained by concatenating a1 and a2
    284 <T> $seq<T> $seq_remove( $seq<T> a, $int i ); // sequence obtained by removing element at position i from a
    285 <T> $seq<T> $seq_insert( $seq<T> a, $int i, T x ); // sequence obtained by inserting element x at position i in a
     287<T> $seq<T> $seq_set( $seq<T> a, $int i, T x ); // seq obtained by replacing element `i` of `a` with `x`
     288<T> $seq<T> $seq_subseq( $seq<T> a, $int start, $int stop ); // subsequence from `start` to `stop-1`
     289<T> $seq<T> $seq_add( $seq<T> a, T x ); // sequence obtained by adding element `x` to the end of `a`
     290<T> $seq<T> $seq_append( $seq<T> a1, $seq<T> a2 ); //  sequence obtained by concatenating `a1` and `a2`
     291<T> $seq<T> $seq_remove( $seq<T> a, $int i ); // sequence obtained by removing element at position `i` from `a`
     292<T> $seq<T> $seq_insert( $seq<T> a, $int i, T x ); // sequence obtained by inserting element `x` at position `i` in `a`
     293<T> void $seq_write( $int n, T * ptr, $seq<T> a );  // write the first `n` elements of `a` to `ptr`, `ptr+1`, ..., `ptr+n-1`.
     294<T> $seq<T> $seq_read( $int n, T * ptr ); // form a sequence by reading `ptr`, `ptr+1`, ..., `ptr+n-1`.
    286295
    287296}}}