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

Robby Findler robby.findler at gmail.com
Tue Feb 27 23:19:43 EST 2007


On 2/27/07, Abdulaziz Ghuloum <aghuloum at cs.indiana.edu> wrote:
>
> 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.

But how can we puzzle that out -- parameterize isn't in r6. Can you
rewrite that with with-exception-handler ?

Robby



More information about the r6rs-discuss mailing list