Re: Design by Contract
| From: | Dmitry Stogov | Date: | Fri, 06 Feb 2015 09:40:00 +0000 |
| Subject: | Re: Design by Contract | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82030@lists.php.net to get a copy of this message | ||
annotations might be useful for DbC, but I doubt if they are more readable.
<<reguire(is_numeric($a) && $a > 0)>>
<<reguire(is_numeric($b) && $b > 0)>>
<<ensure($ret > 0)>>
function foo ($a, $b) {
return $a + $b;
}
Also, to use them, we will have to develop them first (not a trivial task
as well), but may be this is a right road.
Thanks. Dmitry.
On Fri, Feb 6, 2015 at 7:00 AM, Pierre Joye <pierre.php@gmail.com> wrote:
> On Thu, Feb 5, 2015 at 11:36 PM, Dmitry Stogov <dmitry@zend.com> wrote:
> > phpdoc is annotation as well, but to split it into specific attributes we
> > have to write specialized parsers.
> > Other languages support annotation or attributes that may be used more
> > easily.
> >
> > http://docs.hhvm.com/manual/en/hack.attributes.php
>
> Exactly, phpdoc is used as annotation (or comments with some similar
> syntax) but is definitively not aimed to be annotations.
>
> --
> Pierre
>
> @pierrejoye | http://www.libgd.org
>