assert semantic change proposal

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 6 00:19:20 PDT 2014


On 8/5/14, 11:28 PM, Tofu Ninja wrote:
> On Wednesday, 6 August 2014 at 00:52:32 UTC, Walter Bright wrote:
>> On 8/3/2014 4:51 PM, Mike Farnsworth wrote:
>>> This all seems to have a very simple solution, to use something like:
>>> expect()
>>
>> I see code coming that looks like:
>>
>>    expect(x > 2);  // must be true
>>    assert(x > 2);  // check that it is true
>>
>> All I can think of is, shoot me now :-)
>
> How about something like
> @expected assert(x > 2); or @assumed assert(x > 2);
>
> It wouldn't introduce a new keyword, but still introduces the
> expected/assumed semantics. You should keep in mind that you
> might have to make a compromise, regardless of your feelings on
> the subject.

I think "assert" is good to use for optimization, and "debug assert" 
would be a good choice for soft assertions. Care must be exercised with 
tying new optimizations to build flags.

> Also, I am going to try to say this in as respectful a way as I
> can...
>
> Please stop responding in such a dismissive way, I think it is
> already pretty obvious that some are getting frustrated by these
> threads. Responding in a dismissive way makes it seem like you
> don't take the arguments seriously.

I have difficulty figuring how such answers can be considered 
dismissive. The quoted code is considered an antipattern at least e.g. 
at my workplace. (Wouldn't pass review, and disproportionate insistence 
on such might curb one's career.) Even though some might not agree with 
Walter's opinion, it's entirely reasonable to express dislike of that 
code; I don't quite get why that would be consider dismissive. I think 
we're at the point where everybody understands one another, and there 
must be a way to express polite but definite disagreement. What would 
that be?


Thanks,

Andrei



More information about the Digitalmars-d mailing list