Using ASSUME in place of ASSERT in non-assert builds
От | Benjamin Coutu |
---|---|
Тема | Using ASSUME in place of ASSERT in non-assert builds |
Дата | |
Msg-id | 81a3b62b5cdf97b74f30@zeyos.com обсуждение исходный текст |
Ответы |
Re: Using ASSUME in place of ASSERT in non-assert builds
Re: Using ASSUME in place of ASSERT in non-assert builds |
Список | pgsql-hackers |
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 thatASSERT typically expresses a tautology, something the programmer believes to be always true. So in builds where assertionsare 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 compilereither enforces it at runtime (assert builds) or uses it as a hint (non-assert builds). There's no need to writeseparate 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
В списке pgsql-hackers по дате отправления: