Changes between Version 2 and Version 3 of PIL
- Timestamp:
- 10/03/24 11:06:50 (20 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PIL
v2 v3 37 37 - `$set<T>` : finite set of `T`, ops to add, contains, remove, size, ... 38 38 - `$map<T1,T2>` : finite map from `T1` to `T2`, ops to put, get, containsKey, ... 39 - `$fun<T1,T2>` : totalfunctions from `T1` to `T2`39 - `$fun<T1,T2>` : "logic functions": deterministic, total, side-effect free functions from `T1` to `T2` 40 40 - `$tuple<T,...>` : tuples of specified type (similar to struct) 41 41 - `$rel<T,...>` : relations of specified type (set of tuples) … … 50 50 - `t.i` 51 51 - `($tuple<T1,...>){ x1, ... }` 52 - `$ pure$tuple<T1,...> $tuple_write($tuple<T1,...> t, $int i, Ti x);`52 - `$logic $tuple<T1,...> $tuple_write($tuple<T1,...> t, $int i, Ti x);` 53 53 54 54 Mutating expressions: … … 60 60 - `s1 == s2` 61 61 - `($set<T>)$empty` // empty set of type T 62 - `$ pure_Bool $set_in(T x, $set<T> s);` // is x an element of s?62 - `$logic _Bool $set_in(T x, $set<T> s);` // is x an element of s? 63 63 - `$pure $set<T> $set_with($set<T> s, T x);` // s U {x} 64 64 - `$pure $set<T> $set_without($set<T> s, T x);` // s - {x} … … 155 155 === Lambda expressions 156 156 157 These have the form 158 {{{ 159 $lambda (T1 x1, ..., Tn xn) {U1 v1=init1; ... Um vm=initm; expr} 160 }}} 161 where the `Ti` and `Uj` are types, the `xi` and `vj` are variables, and `expr` is an expression in which the only variables that can occur free are the `x1`,..., `xn`, `v1`,..., `vm`. The initializer expressions `initj` are expressions using any variables in scope. The expression has type `$fun<T1,...,Tn; V>`, where `V` is the type of `expr`. 157 There are two kinds of lambda expressions. The first kind defines a procedure, the second a logical function. 158 159 Procedural lambda syntax: 160 {{{ 161 $lambda [U1 v1=init1; ... Um vm=initm;] R (T1 x1, ..., Tn xn) { S1; ... } 162 }}} 163 where 164 * the `Ti` and `Uj` are types 165 * the `xi` and `vj` are variables 166 * R is a type (the return type), which may be void 167 * {S1; ...} is a block (same as in function definition) 168 * the only variables that can occur free in the block are the xi and vj 169 * if R is not void, the block must return a value of type R 170 171 The type of this expression is `R(T1, ..., Tn)`. 172 173 Logic function lambda syntax: 174 {{{ 175 $lambda [U1 v1=init1; ... Um vm=initm;] R (T1 x1, ..., Tn xn) expr 176 }}} 177 where 178 * the `Ti` and `Uj` are types 179 * the `xi` and `vj` are variables 180 * R is a type (the return type), which cannot be void 181 * `expr` is a side-effect-free expression of type R 182 * the only variables that can occur free in `expr` are the xi and vj 183 184 The type of this expression is `$fun<R, T1, ..., Tn>`. 185 186 In both cases, the initializer expressions `initj` are expressions using any variables in scope. 162 187 163 188 ==== Semantics 189 190 FIX THIS: difference between logic and procedural functions... 191 192 164 193 165 194 The lambda expression is evaluated to yield a *closure*: an ordered pair consisting of a dyscope and an expression. The dyscope has variables `v1`, ..., `vm`, initialized by evaluating `init1`, ..., `initm`. The dyscope has no parent scope, it is associated only with the closure. The expression is `expr`. The dyscope is destroyed whenever it becomes unreachable, i.e., whenever no part of the state is assigned the closure.
