Re: RE: RFC: expectations/assertions
| From: | Yasuo Ohgaki | Date: | Wed, 05 Feb 2014 07:58:26 +0000 |
| Subject: | Re: RE: RFC: expectations/assertions | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-72248@lists.php.net to get a copy of this message | ||
Hi Nikita,
On Wed, Feb 5, 2014 at 3:21 PM, Nikita Popov <nikita.ppv@gmail.com> wrote:
> There is a difference between f() and 'f'. The former is a function call,
> the latter a callback. The eval-behavior non-withstanding assert is
> essentially if (!$arg1) { error($arg2); }. So if (!f()) { ... } makes a lot
> of sense, but if (!function() {}) {} makes zero sense. Again, function() {}
> only creates a callback, but does *not* run it. To run it, you'd need
> something like (function(){})().
Thank you for the explanation.
Current assert() is consistent as its spec, since it does not support
callable which is callback function.
I think assert() may accept closure. As I wrote in another mail,
assert(function() {
// some
// useful
// code
});
looks nicer and more modern.
Users are use to this as this kind of form is extensively used in
JavaScript.
I wish to have this form for new assert().
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net