Invariants for methods

bearophile bearophileHUGS at lycos.com
Thu Nov 18 13:07:35 PST 2010


Andrei:

>I don't think they have contracts in interfaces, which is where most difficulty lies.<

There is some discussion about this topic at page 11 here:
http://research.microsoft.com/en-us/projects/contracts/userdoc.pdf


>At any rate, it's not that we can't do it, it was just a large effort that we decided to postpone.<

Postponing its solution (to D3, if needed) is good.


>Is there anything wrong with the workaround I suggested?<

We have had a discussion like this many times, about unittests, ranged integers, nonull references, etc, so probably we think about languages in different ways.

Your workaround is an intelligent trick, I was not able to invent it, and it's a solution better than the one I have used to solve it (ghost fields in debug{}).

In my opinion in a language you must not need to use intelligent tricks to solve basic problems (and referring to the old state is one of the important parts of DbC).

Bye,
bearophile


More information about the Digitalmars-d mailing list