Changeset 39330 in project for wiki/eggref/5/srfi-87
- Timestamp:
- 11/21/20 03:34:02 (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wiki/eggref/5/srfi-87
r39329 r39330 24 24 === Specification 25 25 ==== (Based on R5RS section 4.2.1 Conditionals) 26 library syntax: case <key> <clause1> <clause2> ... 26 library syntax: 27 28 <syntax>case <key> <clause1> <clause2> ...</syntax> 27 29 ===== Syntax 28 30 {{<Key>}} may be any expression. Each {{<clause>}} should have the form 29 31 30 <enscript highlight="scheme"> 31 ((<datum1> ...) <expression1> <expression2> ...), 32 </enscript> 32 <syntax>((<datum1> ...) <expression1> <expression2> ...)</syntax> 33 33 34 34 where each {{<datum>}} is an external representation of some object. All the {{<datum>}}s must be distinct. The last {{<clause>}} may be an "else clause," which has the form 35 35 36 <enscript highlight="scheme"> 37 (else <expression1> <expression2> ...). 38 </enscript> 36 <syntax>(else <expression1> <expression2> ...)</syntax> 39 37 40 38 Alternatively, a {{<clause>}} may be of the form 41 39 42 <enscript highlight="scheme"> 43 ((<datum1> ...) => <expression>) 44 </enscript> 40 <syntax>((<datum1> ...) => <expression>)</syntax> 45 41 46 42 and the last {{<clause>}} may be of the form 47 43 48 <enscript highlight="scheme"> 49 (else => <expression>) 50 </enscript> 44 <syntax>(else => <expression>)</syntax> 51 45 ===== Semantics 52 46 A {{case}} expression is evaluated as follows. {{<Key>}} is evaluated and its result is compared against each {{<datum>}}. If the result of evaluating {{<key>}} is equivalent (in the sense of {{eqv?}}; see section see section [[http://www.swiss.ai.mit.edu/~jaffer/r5rs_8.html#SEC49|6.1 Equivalence predicates]]) to a {{<datum>}}, then the expressions in the corresponding {{<clause>}} are evaluated from left to right and the result(s) of the last expression in the {{<clause>}} is(are) returned as the result(s) of the {{case}} expression. If the result of evaluating {{<key>}} is different from every {{<datum>}}, then if there is an else clause its expressions are evaluated and the result(s) of the last is(are) the result(s) of the {{case}} expression; otherwise the result of the {{case}} expression is unspecified. If the selected {{<clause>}} uses the => alternate form, then the {{<expression>}} is evaluated. Its value must be a procedure that accepts one argument; this procedure is then called on the value of {{<Key>}} and the value(s) returned by this procedure is(are) returned by the {{case}} expression.
Note: See TracChangeset
for help on using the changeset viewer.