Hi Pierre,

On Sun, Feb 22, 2015 at 2:53 AM, Pierre Joye <pierre....@gmail.com> wrote:

> > Assertion is only for development and testing.
> > We need errors or exceptions during development and testing, but
> > not in production. Therefore, errors/exception should not be catched
> > by code in general. Isn't assertion nature?
> >
> > I don't insist not to enable assertion in production environment.
> > There might be software that needs extreme reliability and stability.
> > For these softwares, it makes sense to enable assertions and catch
> > errors/exceptions to do some cleanups.
>
> This last paragraph makes me wonder why in the world assert in PHP is
> still anything valid. If anything it should be removed, to be honest.
>
> Which softwares do not require to be reliable and stable? Most if not
> all PHP written software interact with external inputs, be from APIs
> point of view or from actual users. Per se, they have to be validated
> and errors handling is part of this validation.
>
> I do see some values for asserts in unit tests, but that's pretty much
> all I can think about it.
>
> All in all, I stay with my initial comment, this RFC needs more
> discussion and some other critical questions must be answered before
> this RFC.


We don't put test code checks in production code, do we?
Testing and assertion is to prevent simple bugs, to help finding bugs.
Once development/testing is done, these code will not be needed.

You may think assertion as contracts of code. Once developers ensured
all contracts were kept, contract validations are not needed anymore.
By this proposal, developers can check contracts anywhere in code,
any number of times during development without sacrificing production
code efficiency. This helps to write solid code. Assertion would be
great tool for library/framework developers to prevent users to
abuse/misuse
it also.

Even if we test software with comprehensive manner, software has bugs.
Assertion may help to detected/prevent "unexpected" software behavior.
It's users choice if they enable assertions. Assertions are supposed _not_
to do any useful checks in production, but it may help.

I agree that users may abuse/misuse assertion, but most tools can be
abused/misused like require()/include(). I agree that users _must_
validate all input/output (and PHP should help it). These validations must
be done as usual code, not assertion.

I hope I could explain well enough.

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

Reply via email to