checkedint call removal
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 30 15:42:46 PDT 2014
On 07/31/2014 12:17 AM, Andrei Alexandrescu wrote:
> On 7/30/14, 3:06 PM, Timon Gehr wrote:
>> On 07/30/2014 10:55 PM, Andrei Alexandrescu wrote:
>>> On 7/30/14, 11:31 AM, Timon Gehr wrote:
>>>> On 07/30/2014 07:56 PM, Andrei Alexandrescu wrote:
>>>>> ...
>>>>> case for "assume" to the language creators.
>>>>
>>>> I think there was no such case (yet), only an unsuccessful attempt to
>>>> clear up a misunderstanding based on terminology.
>>>
>>> My perception is you were arguing for a very subtle distinction,
>>
>> My perception is different. Why is this distinction so subtle?
>
> Because it created a long thread in which there's little agreement.
> ...
I've seen mostly agreement so far, but mostly not from you and Walter.
>>> one that would hardly deserve a language feature.
>>> ...
>>
>> version(assert) is a slight generalisation of such a language feature
>> and it is already there. I already noted how the distinction can be
>> implemented approximately in current D, in fact I think this was my
>> first action in this thread.
>>
>> version(assert) assert(...); // assert without effects on -release code
>> generation.
>
> Maybe this is a misundersanding.
I don't see how.
> version(assert) does not mean "assert
> is considered here, else it's completely ignored". It means "assert will
> effect a run-time check".
> ...
Indeed.
// original source:
void main(){
int x=1;
version(assert) assert(x==0);
// ...
}
// after some lowering without the -release switch:
void main(){
int x=1;
assert(x==0); // version statement active,
// check will be performed (and fail)
// ...
}
// after some lowering with the -release switch:
void main(){
int x=1;
// version statement inactive, no check will be performed,
// optimizer never sees the assertion
// ...
}
I.e. no wrong assumptions are passed down to the optimizer under any
circumstances if the assertion is guarded with version(assert).
More information about the Digitalmars-d
mailing list