Re: RE: RFC: expectations/assertions

From: 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 [email protected] to get a copy of this message
2014-02-04 Yasuo Ohgaki <[email protected]>:

> Hi Joe,
>
> On Sun, Feb 2, 2014 at 8:26 PM, Joe Watkins <[email protected]> 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
> [email protected]
>



-- 
github.com/KingCrunch


Thread (44 messages)

« previous php.internals (#72195) next »