checkedint call removal

via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 30 00:17:39 PDT 2014


On Wednesday, 30 July 2014 at 03:32:50 UTC, Walter Bright wrote:
> On 7/29/2014 7:08 PM, Timon Gehr wrote:
>> Of course version(assert) is a language feature. Always 
>> double-check your claims.
>>
>> It's even documented: http://dlang.org/version.html
>
> You're right. My mistake. I'd forgotten about that.
>
>
>>> Not a bit. The distinction utterly escapes me.
>> This is unfortunate, but I don't know what else to say.
>
> I don't either. I still have no idea what the difference 
> between assume(i<6) and assert(i<6) is supposed to be.

main(){
   foobar();
   assert(false==true)
}

With assert():

main(){
   foobar();
}

With assume() the optimizer can:

a: proven_locally(main, (false==true))
no_local_dependencies(a)
all_paths_go_through(a)
b: proven_globally(false==true)
for_all_conditional_expressions_try_to_prove_false()

At this point all conditionals are false and removed.
Complete wipe out. Nothing remains.

here's another version:

foo(){
    assume(true==false);
}

version(RELEASE_MODE){
    foobar(){ foo(); }
}
...

main(){
   foobar();
}





More information about the Digitalmars-d mailing list