John Regehr on "Use of Assertions"

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Sep 5 20:00:43 UTC 2018


On Wed, Sep 05, 2018 at 07:35:46PM +0000, Meta via Digitalmars-d wrote:
[...]
> I don't disagree. I think the only sane way to use asserts as an
> optimization guide is when the program will abort if the condition
> does not hold. That, to me, makes perfect sense, since you're
> basically telling the compiler "This condition must be true past this
> assertion point, because otherwise program execution will not continue
> past this point". You're ensuring that the condition specified in the
> assert is true by definition.  Not having that hard guarantee but
> still using asserts as an optimization guide is absolutely insane,
> IMO.

Sometimes I wonder about a new primitive called 'assume' for optimizer
hints that *cannot* be (easily) verified at runtime.  The current
meaning of 'assert', to most people, appears to be 'abortIfFalse'.
Walter's definition appears to be 'abortIfFalse' + 'assume'. This
conflation has cost us endless debates on the forum, and I'm wondering
if the way out is to stop conflating the two and acknowledge both as
orthogonal, albeit related, primitives.


T

-- 
"Hi." "'Lo."


More information about the Digitalmars-d mailing list