[r6rs-discuss] [Formal] Allow compilers to reject obvious violations

From: Abdulaziz Ghuloum <aghuloum>
Date: Tue Feb 27 20:25:10 2007

On Feb 27, 2007, at 1:51 PM, Jed Davis wrote:
> On Thu, Feb 22, 2007 at 09:06:02PM -0500, William D Clinger wrote:
>>
>> The current draft legitimizes many situations that,
>> according to the R5RS, are clear errors. The draft
>> generally does this by requiring all implementations
>> to raise a &violation exception when the situation
>> arises. That allows portable programs to implement
>> an arbitrarily bizarre semantics for the violation
>> via inappropriate exception handlers.
>
> How arbitrarily bizarre?

I don't know what Will Clinger has in mind, but here is my response.

It can get very bizarre. Imagine the following code (written for
Chez/Ikarus
but translatable to R6RS's exceptions mechanism):

(define (fact n)
   (define result 1)
   (call/cc
     (lambda (k)
        (parameterize ([error-handler
                        (lambda (who str what)
                           (when (= n 0) (k result))
                           (set! result (* result n))
                           (set! n (- n 1))
                           (what))])
           (let f ()
             (call/cc car)
             (f))))))

I will leave it to the reader to puzzle out why this computes factorial.

I think we all agree that this qualifies as "abuse" to the exception
handler
(a sport I might actually enjoy in my spare time, and would
definitely get
fired for if I do it at work). But then what?

Aziz,,,
Received on Tue Feb 27 2007 - 20:24:35 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC