Re: Declare minimum PHP version required?

From: Date: Wed, 05 Feb 2014 06:38:34 +0000
Subject: Re: Declare minimum PHP version required?
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-72240@lists.php.net to get a copy of this message
On Wed, Feb 5, 2014 at 1:19 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > 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. > Yeah, closure is a valid expression but it doesn't tell that closure has to be called. assert("f"); // doesn't call f() as well. So I don't see inconsistency. > Allowing callable as 1st parameter makes behavior consistent. > Closure is useful to keep clean name space. > Could you consider this for new assert? > I'm not sure it's related to assert(). PHP misses construct to create and call closure in one expression. So currently we can't write: assert(function() {return FALSE;}()); but we can write: $f = function() {return FALSE;}; assert($f()); Thanks. Dmitry. > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net >

« previous php.internals (#72240) next »