[Issue 23996] pragma(assume)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 20 14:30:16 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=23996

--- Comment #5 from Bolpat <qs.il.paperinik at gmail.com> ---
(In reply to elpenguino+D from comment #1)
> I think assert(expr) could provide this functionality. Maybe with a
> -checkaction=assume switch? It would also work for contracts, invariants,
> etc then, while also making it trivial to test the assumptions.

I’d say this is really bad design. An assertion and an assumption mean totally
different things. With a compiler flag, you control all of them at once.

Just for an example, an assumption can be used to inform the compiler about a
truth that its optimization routines can make use of and that its optimization
routines could not figure out themselves.
An assert might be used to validate function input, e.g. `isPrime(int x)` might
`assert(x > 0)`.

--


More information about the Digitalmars-d-bugs mailing list