Broken contract programing

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Sun May 17 22:47:37 PDT 2015


Am Wed, 13 May 2015 14:35:53 +0200
schrieb Timon Gehr <timon.gehr at gmx.ch>:

> On 05/13/2015 02:16 PM, Idan Arye wrote:
> >>
> >
> > I think the `in` contracts check should be statically dispatched, so
> > that only the contracts relevant to the reference-type you are calling
> > the method from will be checked.
> 
> https://issues.dlang.org/show_bug.cgi?id=6857

This discussion over there was quite a thriller. From the
first post it looked like a clear case to me: I pass an 'A'
into 'foo', so I deal with 'A's API which includes the
contracts it defines and what methods are declared. Seemed so
logical. Then Walter & Andrei were all like "Guys read up
on OOP, you seem not to understand the details! The way we
handle contracts is the only possible way!", passing the
argument by authority up to Meyer.
And finally Meyer himself had to think for a moment before
saying the static type should probably be checked for
contracts, not the dynamic one and his book wasn't explicit
about it either, but it could be deduced.

So much energy went into writing endless repetitive comments,
that could have been put into trying to understand the issue
at hand and revalidating ones views and memories when four or
more people hint at a blind spot.
Maybe one has to be in the situation where one constantly
has to put energy into proving to people who made up a new
feature in 5 minutes, why exactly it is not going to work.

Anyways the bug is pre-approved and looking for someone to
hack on the compiler.

-- 
Marco

P.S.:
I just noticed I had a misconception about in-contracts, too.
Where I thought they would be inherited per method override,
it is actually the case that not copying the in-contract
states that my derived method will work with any input. So
this was all very educational at least.


More information about the Digitalmars-d mailing list