Formal comment #66 (defect) The implicit cond in guard expressions is not a good idea Reported by: Abdulaziz Ghuloum Component: exceptions Version: 5.91 Section 14.1 on page 73 of the R5.91RS draft specifies the syntax of guard expressions as: (guard ( ...) ) Syntax: Each should have the same form as a cond clause. The syntax is constructed on the assumption that conditional dispatch on the condition type is the default action that would be performed in the guard handler. This is not necessarily the case. Moreover, the syntax is alien since there is no other construct in the language that has an implicit cond. Examples from the draft: (guard (condition (else (display "condition: ") (write condition) (newline) 'exception)) (+ 1 (raise 'an-error))) (guard (condition (else (display "something went wrong") (newline) 'dont-care)) (+ 1 (raise 'an-error))) First, the (condition ...) syntax does not imply variable binding at all. After all (cond ...) does not bind anything and the two forms look sufficiently similar to cause confusion. Second, a programmer may wish to perform some action before the conditional dispatch, after the conditional dispatch, or may not wish to perform the conditional dispatch at all. There is no reason to assume that conditional dispatch is the only thing a user wants. Example: Logging an error message using the current syntax: (guard (condition (else (let ([msg (format-condition condition)]) (log msg (current-error-port)) (cond ...)))) ) Suggestion: Many ideas are plausible. One possibility is to specify the syntax of guard expressions as: (guard ) The first and third examples therefore translate to: (guard condition (begin (display "condition: ") (write condition) (newline) 'exception) (+ 1 (raise 'an-error))) (guard condition (let ([msg (format-condition condition)]) (display msg (current-error-port)) (cond ...)) ) Thank you. Aziz, RESPONSE: The translation of the examples is incorrect, as the `guard' form also re-raises the exception if it isn't handled in the conditional. The `guard' form encodes a common usage pattern for exception handling. As a data point, "dispatch or optional re-raise" is the default pattern for the handling constructs in C++, Java, and ML, and presumably their choices were made for the same reason as the choices with `guard'. The examples are hardly representative, as they are taken verbatim from SRFI 34, which did not assume a matching condition system. Moreover, they are meant to illustrate the various cases distinguished by the semantics rather than present common use cases. The editors will try to improve the examples in the next draft.