[Issue 6857] Precondition contract checks should be statically bound.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 4 22:57:31 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6857



--- Comment #46 from Don <clugdbug at yahoo.com.au> 2012-05-04 22:58:38 PDT ---
(In reply to comment #45)
> (In reply to comment #44)
> > But going by comment 26, there is no breakage of correct OOP behaviour
> > involved.  So how is this relevant?
> 
> This has already been covered. We're going in circles.

Walter, you haven't understood this at all. None of us have claimed that the
program ever gets into a wrong state. Let me try another way.
Given a module which consists of:
----------
struct F {
   void foo(int n) in { assert( n > 0); } body {}
}

void xyzzy(F f)
{
    f.foo(-1);
}
----------
A theorem prover, or even a compiler that did basic range checking for
preconditions, should raise an error at compile time. Not at run time when it's
actually called with an F, but at compile time. Nothing controversial there.

Now, change F from a struct to a class. We believe that the code should still
fail to compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list