Invariants for methods

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Nov 18 13:38:51 PST 2010


On 11/18/10 1:07 PM, bearophile wrote:
> 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

I don't see anything remotely clever in the solution I suggested. At 
some point it's worth starting to use the language to devise solutions 
to problems instead of inventing a new feature for any problem that 
comes about.

Andrei


More information about the Digitalmars-d mailing list