Re: RE: RFC: expectations/assertions
| From: | Sebastian Krebs | Date: | Tue, 04 Feb 2014 13:11:00 +0000 |
| Subject: | Re: RE: RFC: expectations/assertions | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-72195@lists.php.net to get a copy of this message | ||
2014-02-04 Yasuo Ohgaki <yohgaki@ohgaki.net>:
> Hi Joe,
>
> On Sun, Feb 2, 2014 at 8:26 PM, Joe Watkins <pthreads@pthreads.org> wrote:
>
> > https://wiki.php.net/rfc/expectations
> >
>
> Current assert() may call functions
>
> php > assert(version_compare(PHP_VERSION, '4', '<'));
>
Note, that not assert() calls the function, but you. You already call
"version_compare()" and pass the return value to "assert()". While this
works it is not really recommended, because it is executed, even if you
disable assertions. Additionally the assertion message after failed
assertions is not really useful
php > assert('version_compare(PHP_VERSION, "4", "<")');
>
> Warning: assert(): Assertion failed in php shell code on line 1
>
> but it seem not closure like this
>
> php > assert(function() {return 2>1;});
> php > assert(function() {return 2<1;});
>
assert('2>1');
works
>
> Is it possible write closure like this?
>
> Regards,
>
> --
> Yasuo Ohgaki
> yohgaki@ohgaki.net
>
--
github.com/KingCrunch