DIP 1009--Improve Contract Usability--Preliminary Review Round 1
Moritz Maxeiner via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 28 05:34:59 PDT 2017
On Wednesday, 28 June 2017 at 12:17:36 UTC, Enamex wrote:
> Why do we need to name the result at all?
>
> Any conflicts with using
> `out(out > 0, "message")`
No conflict AFAICT. I personally don't like it, though.
> `out(return > 0, "message")`?
Yes, see [1]
> `out(someCond($), "message")`?
Overloading symbols with context dependent meaning is one more
step into obfuscation.
> 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.
> 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
More information about the Digitalmars-d
mailing list