Re: Declare minimum PHP version required?
| From: | Yasuo Ohgaki | Date: | Tue, 04 Feb 2014 21:19:08 +0000 |
| Subject: | Re: Declare minimum PHP version required? | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-72215@lists.php.net to get a copy of this message | ||
Hi Dmitry,
On Wed, Feb 5, 2014 at 3:30 AM, Dmitry Stogov <dmitry@zend.com> wrote:
> I don't think PHP needs new language constructs for assertions.
> Actually, the code from your example may be implemented as two calls to
> assert().
>
> assert(extension_loaded('foo'), 'You need foo module');
> assert(extension_loaded('bar'), 'You need bar module');
>
> I think it's much clear then inventing new syntax.
> With Joe's proposal these asserts might be completely eliminated.
> And it's backward and forward compatible :)
>
> BTW: I didn't follow all the discussion, so I may miss some points.
>
Thank you for reply.
Since new assert() could be eliminate runtime overheads, it may be the
way to go. Regarding assert(), it seems current assert() is inconsistent
for function calls.
Function call works
php > function f() {return FALSE;}
php > assert(f());
Warning: assert(): Assertion failed in php shell code on line 1
Closure does not
php > assert(function() {return FALSE;});
php >
Closure is a valid expression and it should be allowed. IMO.
Allowing callable as 1st parameter makes behavior consistent.
Closure is useful to keep clean name space.
Could you consider this for new assert?
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net