DIP 1009--Improve Contract Usability--Preliminary Review Round 2 Begins
Nick Treleaven via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 28 04:04:23 PDT 2017
On Friday, 21 July 2017 at 13:51:05 UTC, Mike Parker wrote:
> DIP 1009 is titled "Improve Contract Usability".
>
> https://github.com/dlang/DIPs/blob/master/DIPs/DIP1009.md
I think the proposed in/out expression contracts should require
pure expressions. In the rare case that impurity is required, the
old syntax can be used. This makes the proposal more useful.
Otherwise, the expression would have to be awkwardly wrapped in
`()pure => expr` code to enforce this (without requiring purity
of function body too). It's too late to require purity for
existing contract syntax, but we have an opportunity here.
One option to solve the out contract ambiguity and aid parsing by
tools is to require 'do' after out contract expressions. It
allows the syntax `out(expression) do {...}`, even when
expression is a single identifier that should be interpreted as a
boolean expression.
More information about the Digitalmars-d
mailing list