DIP 1009--Improve Contract Usability--Preliminary Review Round 1

MysticZach via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 21 10:39:29 PDT 2017


On Wednesday, 21 June 2017 at 15:18:21 UTC, Timon Gehr wrote:
> On 21.06.2017 02:51, MysticZach wrote:
>> 
>> I think people could get used to the cognitive dissonance.
>
> That's really not what D is about.

My counterargument to that is that it's possible that the 
cognitive dissonance only occurs because of what people are used 
to, rather than what is inherent to the syntax.

>> I've already gotten used to it just by writing this DIP.
>
> I think it is likely that you are an outlier.

Well my impression was that Walter liked it too, although I could 
have misinterpreted his comment here:

http://forum.dlang.org/post/ogvt66$1bcp$1@digitalmars.com

>> If such an alternative checking system is utilized,
>
> If so, there should be a way to hook into the checking logic. 
> This has nothing at all to do with contract syntax. asserts and 
> contracts are coupled already, as in-contracts form a 
> disjunction on override by catching AssertErrors.

Improving the checking logic interface may solve at a higher 
level the problem I'm trying to solve at a very low one, with 
mere syntax changes, and it might be (is probably?) the best way 
forward.

>> the syntax for  writing contracts should be as easy
>> for them as for those using `assert`.
>
> Maybe, but your DIP does not pull its own weight as long as the 
> latter syntax is not a notable improvement over what we have 
> now.

Well, my view is that my DIP is actually a very lightweight 
syntax change, and an equally lightweight improvement in contract 
syntax, so it's a lost-cost, mild improvement . The cognitive 
dissonance argument is the main one against it, and I really 
don't know if that dissonance is based on fundamental flaws in 
the way I'm thinking about it, or just the "Shock of the New" 
[1]. If allowing contracts in the function body really is a 
fundamentally flawed concept, then I won't keep advocating for it.

> H. S. Teoh's counter-proposal is, and I think your DIP has a 
> much higher chance of acceptance if you go with it.

I'm not actually worried about whether the proposal is accepted 
or not, as long the best ideas and arguments come forward and are 
heard. I have more faith in the process than I do in any 
particular proposal.

As far as Teoh's proposal, I would say that its quality is highly 
correlated to the percentage of projects that find built-in 
`assert` adequate to their needs, which is hard to assess 
precisely - the better `assert` is, or can be made to be, the 
better Teoh's proposal is, I'd say. Moritz [2] suggests solving 
the problem by decoupling `in` and `out` contract syntax from the 
checking logic. This seems like a good way to go too. But I'd 
like to see a little more justification for it.

[1] Robert Hughes documentary, "The Shock of the New" 
https://www.youtube.com/watch?v=J3ne7Udaetg
[2] 
http://forum.dlang.org/post/uzzwmgqoqxuxhusjvlcg@forum.dlang.org


More information about the Digitalmars-d mailing list