DIP 1009--Improve Contract Usability--Preliminary Review Round 1
Enamex via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 28 07:09:40 PDT 2017
On Wednesday, 28 June 2017 at 12:34:59 UTC, Moritz Maxeiner wrote:
> On Wednesday, 28 June 2017 at 12:17:36 UTC, Enamex wrote:
>> `out(return > 0, "message")`?
>
> Yes, see [1]
It has the already used `typeof(return)` going for it, though.
A big point against it IMO would be its moving further from
`return`'s
signal that a function scope is exited at that line (instead it
could
be a variable assignment which is meh (usage in a contract check
is OK
since we're already outside the function)).
>> `out(someCond($), "message")`?
>
> Overloading symbols with context dependent meaning is one more
> step into obfuscation.
True.
>> So using either `out` or `return` or `$` or whatever to always
>> refer to the return value of the function. Just something
>> that's already relevant and used instead of `__result`.
>
> Well, `__result` is already implemented and usable, so I would
> argue it is thus relevant.
It's not used in the wild yet though :T
>> R foo(Args...)(Args args) {
>> out(return > bar && ensured(return), "foo() fudged its
>> return");
>
> Contracts inside function bodies should not be allowed imho.
>
> [1] http://forum.dlang.org/post/oihbot$134s$1@digitalmars.com
I was going with the current 'Proposal' syntax in the DIP's
document. There
a more recent proposal here?
More information about the Digitalmars-d
mailing list