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

From: Marcin 'Qrczak' Kowalczyk <qrczak>
Date: Thu Oct 26 17:52:13 2006

William D Clinger <will_at_ccs.neu.edu> writes:

>> If (lambda () (cons 1 2 3)) cannot possibly be correct, then what about:
>> (lambda () ((begin cons) 1 2 3)),
>> (lambda () ((if #t cons list) 1 2 3)), and
>> (lambda () ((f) 1 2 3)) where f may/will return cons?
>
> On my reading of the draft R6RS, the first three cannot
> possibly be correct, and might be rejected at compile
> time. The last might be correct, and will not be rejected
> at compile time (unless the compiler has more information
> available to it than you have told us).

I think it's better to define statically valid code unambiguously,
and thus allow all that at compile time.

Anyway, what if such code is present in the source and not executed?

I claim that then it makes no sense to allow the compiler to reject it,
although a warning is fine. Because there is no significant difference
between a never called (cons 1 2 3), and this:

   (define (fun1 f) (f 1 2 3))
   (define (fun2 f) (if f #f (fun1 f))
   (fun2 cons)

which contains a call to (fun1 f), i.e. (fun1 cons), i.e. (cons 1 2 3),
which is nevertheless not executed.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak_at_knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/
Received on Thu Oct 26 2006 - 17:51:03 UTC

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