[r6rs-discuss] Compile-time detection of contract violations

From: Felix Klock <pfr6rs>
Date: Wed Nov 1 03:15:56 2006

On Nov 1, 2006, at 2:11 AM, William D Clinger wrote:

> I am posting this as an individual member of the Scheme
> community. I am not speaking for the R6RS editors.
>
> Abdulaziz Ghuloum addressing Mike Sperber:
>> Are you sure this program should return 1? From what I understand
>> from
>> this thread so far, the above is not a correct program and thus is
>> meaningless (it may be rejected by some implementations, may return 1
>> under others, and may return (1 . 2) under a third). If the above
>> *is*
>> a correct program that returns 1, then I need further explanation of
>> its meaning when run under an "unsafe" declaration. I sure hope that
>> declarations do not change the semantics of correct Scheme programs.
>
> I suspect that Abdulaziz's understanding, stated above,
> is based in part upon my analysis of language that appears
> in the current draft of R6RS, section 9.22, page 56.
>
> Mike's position, I believe, is that the language in section
> 9.22 of the current draft does not reflect the intent of
> the editors, and should be repaired. I accept Mike's
> analysis.

Just so we are clear on what part(s) of 9.22 do not reflect the
intent of the editors:

Are we talking about:
1.) The encouragement of implementations to raise &syntax exceptions
when encountering subexpressions with violations
2.) The permission of implementations to raise &warning exceptions
when encountering subexpressions with "inevitable" violations
3.) Both of the above
4.) Something else

Mike's position, as stated thus far, sounds to me like it could be in
opposition to both (1.) and (2.) above, or just (1.) above, since the
default handler is supposed to just return when encountering a
&warning. That is, the runtime might signal a &warning when it
compiles the entirety of Robby's expression, but that &warning will
be discarded by the default handler, and evaluation of the compiled
expression proceeds as expected. The runtime might alternatively
signal a &warning if it compiles the subexpression while in the
dynamic extent of the exception handler installed by Robby's
expression, which is then caught by Robby's handler, but that will
just result in the expression evaluating to 1, as Mike predicts.

Thus, to clarify my understanding of Mike's position, I ask whether
code like the following is specified as returning 1, 2, either, or ...?

(call-with-current-continuation
   (lambda (exit)
     (with-exception-handler (lambda (x) (exit 2))
       (with-exception-handler (lambda (x) (exit 1))
           (lambda () (cons 1 2 3))))))))

That is, a JIT compiler might wait until it was evaluating the
innermost (with-exception-handler ...) to actually raise a &warning
about the (cons 1 2 3). Such systems might then return 2 as their
result, right?

-Felix

p.s. I personally liked the idea of being able to install customized
warning handlers for e.g. ill-formed cons invocations. I admit that
I do not know know where such a thing would actually be of use in a
portable R6RS-compliant "script" or "library" (as opposed to some non-
standard repl), except perhaps in invocations of the eval procedure.
Still it sounded like an interesting idea to play with. Perhaps
&warnings are an area for future experimentation rather than
something to be standardized in R6RS.
Received on Wed Nov 01 2006 - 03:15:24 UTC

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