Changes between Version 13 and Version 14 of PIL


Ignore:
Timestamp:
10/05/24 16:53:06 (19 months ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PIL

    v13 v14  
    155155
    156156Expressions: these are all side-effect-free, assuming `expr1`, ... are side-effect-free.
    157 - `t1 == t2` : the two tuples have the same number of components and corresponding components are equal
    158 - `t.i` : the value of component `i` (a constant integer) of tuple `t`
    159 - `($tuple<T1,...>){ expr1, ... }` : the literal tuple with the given list of components.
    160 - `t.[i : expr1]` : the tuple which is the same as `t`, except for component `i` (a constant integer), which has value `expr1`
     157- `t1 == t2`
     158 * the two tuples have the same type and corresponding components are equal
     159- `t.(i)`
     160 * the value of component `i` (a constant integer) of tuple `t`
     161- `($tuple<T1,...>){ expr1, ... }`
     162 * the literal tuple with the given list of components.
     163- `t[.(i) := expr1]`
     164 *the tuple which is the same as `t`, except for component `i` (a constant integer), which has value `expr1`
    161165
    162166Mutating expressions:
    163 - `t.[i] = expr` : sets component `i` of tuple `t` to `expr`
     167- `t.(i) = expr` : sets component `i` of tuple `t` to `expr`
    164168
    165169== Sets
     
    167171Side-effect free expressions:
    168172- `s1 == s2`
    169 - `($set<T>)$empty`   // empty set of type T
     173 * the two sets have the same type and contain the same elements
     174- `($set<T>)$empty`
     175 * empty set of type T
    170176
    171177Logic functions:
    172178- `$pure $logic $bool $set_contains($set<T> s, T x);`
    173  * is `x` an element of `s`?
     179 * is x an element of s?
    174180- `$pure $logic $set<T> $set_with($set<T> s, T x);`
    175  * `s` U {`x`}
     181 * s U {x}
    176182- `$pure $logic $set<T> $set_without($set<T> s, T x);`
    177  * `s` - {`x`}
     183 * s - {x}
    178184- `$pure $logic $set<T> $set_union($set<T> s1, $set<T> s2);`
    179  * `s1` U `s2`
     185 * s1 U s2
    180186- `$pure $logic $set<T> $set_difference($set<T> s1, $set<T> s2);`
    181  * `s1`-`s2`
     187 * s1-s2
    182188- `$pure $logic $set_intersection($set<T> s1, $set<T> s2);`
    183  * `s1`  \cap `s2`
     189 * s1  \cap s2
    184190- `$pure $logic T[] $set_elements($set<T> s);`
    185  * returns the set of elements of `s` as an array in some deterministic order
    186 - `$pure $logic $bool $set_isSubsetOf($set<T> s1, $set<T> s2);`
    187  * is `s1` a subset of `s2`?
     191 * returns the set of elements of s as an array in some deterministic order
     192- `$pure $logic $bool $set_subset($set<T> s1, $set<T> s2);`
     193 * is s1 a subset of s2?
    188194- `$pure $logic $set<U> $set_map($set<T> s, $fun<T,U> f);`
    189  * { `f`(`x`) | `x` in `s`}
     195 * { f(x) | x in s}
    190196- `$pure logic $set<T> $set_comprehension($set<T>, $fun<T,$bool> p);`
    191  * { `x` in `s` | `p`(`x`) }
     197 * { x in s | p(x) }
    192198
    193199Mutating procedures:
     
    202208Expressions:
    203209- `a1 == a2`
     210 * the two arrays have the same type and length and corresponding elements are equal
    204211- `a[i]`
     212 * the `i`-th element of `a`
     213- `a[i:=x]`
     214 * the sequence which is the same as `a`, exception in position `i`, where it has value `x`
    205215- `(T[]){ expr1, ... }`
    206216
     
    209219- `$pure $logic T[] $seq_uniform($int n, T val);`
    210220- `$pure $logic $int $length(T[] a);` // length of a
    211 - `$pure $logic T[] $seq_write(T[] a, int i, T x);`  // a[i:=x]
    212221- `$pure $logic T[] $seq_subseq(T[] a, int i, int n);`  // a[i..i+n-1]
    213222- `$pure $logic T[] $seq_without(T[] a, int i);` // a with position i removed
     
    229238==  Maps
    230239
    231 Non-mutating expressions:
     240Side-effect-free expressions:
    232241- `m1 == m2`
    233242- `($map<K,V>)$empty`
    234 - `$logic V $map_get($map<K,V> K key);`
    235 - `$logic $bool $map_containsKey($map<K,V> map, K key);`
    236 - `$logic $bool $map_containsValue($map<K,V> map, V val);`
    237 - `$logic $map<K,V> $map_with($map<K,V> map, K key, V val);`
    238 - `$logic $map<K,V> $map_without($map<K,V> map, K key);`
    239 - `$logic $set<K> $map_keys($map<K,V> map);`
    240 - `$logic $set<$tuple<K,V>> $map_entries($map<K,V> map);`
     243
     244Logic functions:
     245- `$pure $logic V $map_get($map<K,V> K key);`
     246- `$pure $logic $bool $map_containsKey($map<K,V> map, K key);`
     247- `$pure $logic $bool $map_containsValue($map<K,V> map, V val);`
     248- `$pure $logic $map<K,V> $map_with($map<K,V> map, K key, V val);`
     249- `$pure $logic $map<K,V> $map_without($map<K,V> map, K key);`
     250- `$pure $logic $set<K> $map_keys($map<K,V> map);`
     251- `$pure $logic $set<$tuple<K,V>> $map_entries($map<K,V> map);`
    241252
    242253Mutating procedures:
     
    246257- `void $map_addAll($map<K,V> * this, $map<K,V> that);`
    247258
    248 
    249259== Heaps
    250260
    251261There is a single heap for dynamic allocation.  The following built-in procedures are provided:
    252262
    253 - `T* $new<T>()`: creates an object `A` of type `T` in heap and returns `&A`.
    254 - `T* $alloc<T>(int n)`: creates an array `A` of length `n` of `T` in heap and returns `&A[0]`.
    255 - `void $free<T>(T* p)`: frees the object referred to by `p`, the pointer returned by an earlier call to `$new` or `$alloc`.
     263- `T* $new<T>()`
     264 * creates an object `A` of type `T` in heap and returns `&A`.
     265- `T* $alloc<T>(int n)`
     266 * creates an array `A` of length `n` of `T` in heap and returns `&A[0]`.
     267- `void $free<T>(T* p)`
     268 * frees the object referred to by `p`, the pointer returned by an earlier call to `$new` or `$alloc`.
    256269
    257270
     
    261274* can there be nondeterministic expressions, i.e., expressions that evaluate to a set of values instead of one value?
    262275* how to implement C's malloc?
     276* what to return when something is wrong, e.g., $map_get$ when the specified key is not in the map (default value of type?)
    263277
    264278Ideas on malloc: