Hi,

On 1 April 2021 09:24:54 BST, Arnold Daniels <arnold.adaniels...@gmail.com> 
wrote:
>The documentation of `assert`
>([https://php.net/assert)](https://www.php.net/manual/en/function.assert.php))
>states that's debugging only. This is further enforced by php.ini flags
>to disable assertions in production.

This is, in a sense, looking at things the wrong way around: the main feature 
of the built-in assert() statement is that it can be disabled in production, 
and the assertion code will not run at all. That feature is useful if you want 
to write assertions that run in development but have zero performance cost in 
production.

If you leave them switched on permanently, the advantage of using the built-in 
assert() over writing your own becomes very small - the definition would be two 
simple lines of code. There's nothing to stop you doing that, though; the 
documentation is just giving advice.

The two libraries you linked to concentrate on a very different feature: 
concisely writing certain common conditions, such as type and range checks. It 
might seem reasonable to include common features like this in the language, but 
the fact that you linked two different libraries demonstrates why that might 
not be a good idea: the API and feature set are hard to get right. Once a 
feature is added to the language it is very difficult to change.

Regards,

-- 
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to