--- This message is a formal comment which was submitted to formal-comment_at_r6rs.org, following the requirements described at: http://www.r6rs.org/process.html --- Summary: The implicit cond in guard expressions is not a good idea Name: Abdulaziz Ghuloum Email: aghuloum_at_cs.indiana.edu Issue Type: Defect Priority: Minor Component: Exceptions Version: 5.91 Section 14.1 on page 73 of the R5.91RS draft specifies the syntax of guard expressions as: (guard (<variable> <clause1> <clause2> ...) <body>) Syntax: Each <clause> 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 <clause1> <clause2> ...) syntax does not imply variable binding at all. After all (cond <clause1> <clause2> ...) 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 <clause1> <clause2> ...)))) <expr>) Suggestion: Many ideas are plausible. One possibility is to specify the syntax of guard expressions as: (guard <variable> <handler-expression> <body-expression>) 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 <clause1> <clause2> ...)) <expr>) Thank you. Aziz,,,Received on Sat Oct 28 2006 - 06:45:17 UTC
This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC