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

MysticZach via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 24 04:05:07 PDT 2017


On Saturday, 24 June 2017 at 02:31:09 UTC, Solomon E wrote:
> I think my proposal to add another use of semicolon in 
> parentheses, like `foreach` or `for` but not the same as 
> either, was needlessly complicated.

It's very popular, actually. :)

> in (a)
> out (result) (a)

This resembles template function declarations. Both proposals 
resemble something else that they are not. Your proposal for 
`out` is attractive, actually, because the semantics of foreach 
are closer to what we're looking for than are the semantics of 
template declarations.

> as syntax sugar where each (a) lowers to
> {assert(a);}
> and in future can lower to something else, to renovate contract 
> implementation

The foreach syntax can be just as easily lowered:

out(result; a)

...to:

out(result) {assert(a);}

That also includes the optional message.

out(result; result < 1, "alert!")

...lowers to:

out(result) { assert(result < 1, "alert!"); }

> That's so much easier, in every way.

There's no intention of making it complicated!


More information about the Digitalmars-d mailing list