Re: Design by Contract
| From: | Dmitry Stogov | Date: | Thu, 05 Feb 2015 11:46:16 +0000 |
| Subject: | Re: Design by Contract | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-81901@lists.php.net to get a copy of this message | ||
On Thu, Feb 5, 2015 at 2:38 PM, Patrick Schaaf <php@bof.de> wrote:
> Am 05.02.2015 12:14 schrieb "Dmitry Stogov" <dmitry@zend.com>:
> >
> > For php it may look like the following:
> >
> > function foo()
> > require(<input-assert-expression>)
> > ensure(<output-assert-expression>)
> > {
> > ...
> > }
> >
> > It would require only one new reserved word "ensure".
>
> How would one access the function return value in the
> output-assert-expression?
>
good point. we may use a reserved name. e.g. $result.or $return_value
> And what about side effects in these expressions? Could they be suppressed
> / made into errors somehow?
>
I afraid, we won't be able catch possible side effects of assert
expressions.
For now, we may just relay on user, in the same way as with assert() now.
Thanks. Dmitry.
> best regards
> Patrick
>