Hello,

I noticed that Andres recently introduced pg_assume into the codebase - great 
addition!

That got me thinking: some projects (like PHP) map the ASSERT macro to ASSUME 
in non-assert builds. The rationale is that ASSERT typically expresses a 
tautology, something the programmer believes to be always true. So in builds 
where assertions are compiled out, we can still pass that information to the 
optimizer via ASSUME.

This approach has the advantage of keeping the semantics consistent: developers 
write ASSERT(...) as usual, and the compiler either enforces it at runtime 
(assert builds) or uses it as a hint (non-assert builds). There's no need to 
write separate logic or macros depending on build type. And we get the benefits 
of both safety and optimization.

Was this strategy considered before introducing pg_assume, or did I miss that 
part of the discussion?

Cheers

-- 

Benjamin Coutu
http://www.zeyos.com


Reply via email to