DIP 1009--Improve Contract Usability--Preliminary Review Round 1
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jun 22 14:10:53 PDT 2017
On 22.06.2017 22:43, jmh530 wrote:
> On Thursday, 22 June 2017 at 20:19:59 UTC, Timon Gehr wrote:
>> On 22.06.2017 22:02, jmh530 wrote:
>>>
>>> The whole double parentheses is a bit ugly to me. Is there any
>>> problem with
>>> out(return > 0)
>>
>> out(a => {
>> void foo()out(b => a == b){ return a; }
>> return foo()>0;
>> }());
>
> I'm confused. The compiler should know that these returns are inside
> lambdas.
The point is that two results are in scope, so you cannot call both of
them 'return'. It's a corner case, but you asked for any problems.
> Also, foo should not return void
Oops. That's a typo. Fixed version:
out(a => {
int foo()out(b => a == b){ return a; }
return foo()>0;
}())
> and I'm not sure what the
> extra set of parentheses are for at the end.
That's calling the lambda.
Version that works today:
int bar()out(a){
int foo()out(b){
assert(a==b);
}body{
return a;
}
assert(foo()>0);
}body{
return 2;
}
More information about the Digitalmars-d
mailing list