Topic: case statement
Topic: conditional control by guards
Topic: conditional statement language
Topic: else clause
| |
Summary
Test chains are a common generalization of conditional selection. Instead of a single conditional guarding a statement, a list of conditionals control execution of a list of statements. Each conditional is tested in turn with true conditionals executing the corresponding statement before terminating or continuing the test chain.
Conditionals may be control-returning functions which allow the test chain to be an expression for evaluation. By cascading tests, very complicated conditionals can be specified with intermixed actions, but they may be hard to understand because action depends on the sequence executed. Many test chains can be re-written as case statements using shared procedures. Others can be re-written as several control-returning functions. (cbb 5/80)
Subtopic: short-circuit evaluation of test chain
Quote: C's && and || operators guarantee left-to-right, short-circuit evaluation; their predictable behavior is frequently used [»ritcDM7_1978c]
| QuoteRef: mccaJ_1960 ;;184 conditional expressions (predicate -> exp, predicate -> exp etc) e.g., p or q is (p->q, T->F).
| Quote: in Pancode, use 'also if' instead of 'else if' [»jonsD8_1987, OK]
| QuoteRef: buxtJN_1962 ;;195 test chains: all at same indentation, implied and, explicitly or in margin. can have regular statements interspersed. arranged vertically.
| QuoteRef: storEF_1970 ;;23-4 general statement is list of clauses % (condition list : operation-list in brackets. on condition list, execute operation list and terminate statement as true (:) is the null always true clause
| QuoteRef: wegbB5_1974 ;;3 conditionals by bool -> exp, while block exit conditionals by bool => exp (like lisp or ::)
| QuoteRef: bartCW7_1974 ;;293 Wulf: Bliss evaluating case labels; each matching case is executed
| QuoteRef: smitJW_1970 ;;208 conditional expressions by (x=1:5; x=2:6; 20)
| Subtopic: problems as taxon vs. program as sequence
Quote: understanding a program requires sequence information, but problems present taxon information, e.g., "are hard juicy objects ever roasted" [»simeME1_1977a]
| Subtopic: evaluate all terms first
Quote: in SL5, 'e1 and e2' has the value of e2 if both succeed, else the value of e1 [»hansDR5_1978]
| QuoteRef: boscR9_1973 ;;6 flow of control -- index on first element -- if rest of alternative fails the whole rule fails.
| QuoteRef: hallJC5_1974 ;;41 sequention (apply A then B) by .larrow. .eq. d=a .larrow. b, succeeds if both directives succeed.
| QuoteRef: hallJC5_1974 ;;41 forward alternation: a!b succeeds if either a or b succeeds but no backtrack.
| Subtopic: nested, sequential conditional operators
QuoteRef: wileDS11_1973 ;;34 then and else like LISP i.e., x else y == y when x is empty else x
| QuoteRef: wileDS11_1973 ;;34 x then y == y when x is non-empty else nil (this can be derived
| QuoteRef: wileDS11_1973 ;;35 x excludes y == y when x is empty else nil
| QuoteRef: wileDS11_1973 ;;35 or::else, and::then, not x:: x excludes true [renaming e.g., x else Y = if x nil then y else x]
| QuoteRef: wileDS11_1973 ;;49 relations return their monadic argument when true e.g., 1<2 == 1 (<2) = 1 and (i le)b le j is a range check
|
Related Topics
Topic: case statement (25 items)
Topic: conditional control by guards (17 items)
Topic: conditional statement language (5 items)
Topic: else clause (11 items)
|