Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72240 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40010 invoked from network); 5 Feb 2014 06:38:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2014 06:38:39 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 74.125.82.49 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 74.125.82.49 mail-wg0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:44071] helo=mail-wg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/D0-22810-D6CD1F25 for ; Wed, 05 Feb 2014 01:38:38 -0500 Received: by mail-wg0-f49.google.com with SMTP id a1so13486613wgh.4 for ; Tue, 04 Feb 2014 22:38:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=prevMjSFEiBh+GSKQssbl3nKGksXlL7g5kWihs8H8+c=; b=YP4ka4hOP5x+iUGnRAj+mSzlgBbyG2Nozsr0Km4+kluBa/J1pBvxm9IDSl8AVT23+M e4lr1IlC3kZ2x+ObpodpEa5d3Ctl02UNWLKT/TVTsSE3i02NCqthpkvfhIpZrpZBaGcS 0F+Gq/i10X/1w+fqsyLGjW49j0nk/1RIo1JF6QieNaRilLTr1UuapH0rgXlyKIxgQ51q CM3ka1ip2oVIV+a4vzHru+j30uWbekgF1jO75hfHLI7JMVfCaXxeMm1QhizDVkfDpyNC EWUT8tZkYV27SNBriAg0nB8v0TYABpZYQ+YgZr6LEy/pv1YnxhixQwxOC4mCnZVZ9NDa nZtg== X-Gm-Message-State: ALoCoQnPFOeTimNO9j4h0oQ5ElN1HDCjYojE5zA3ha4U7AitnwqSrh99wiAWnu3Q1wOByCKGXnW28316Kg0t54mLkge6rfVuTO3lr1EU9PvbL+t3zHIbXF9fzeO++gSuLY5BMO2I4cXc MIME-Version: 1.0 X-Received: by 10.180.24.227 with SMTP id x3mr1084119wif.41.1391582314134; Tue, 04 Feb 2014 22:38:34 -0800 (PST) Received: by 10.227.91.196 with HTTP; Tue, 4 Feb 2014 22:38:34 -0800 (PST) In-Reply-To: References: <52EF4BF8.60005@sugarcrm.com> Date: Wed, 5 Feb 2014 10:38:34 +0400 Message-ID: To: Yasuo Ohgaki Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f46d044283b085a14f04f1a30175 Subject: Re: [PHP-DEV] Declare minimum PHP version required? From: dmitry@zend.com (Dmitry Stogov) --f46d044283b085a14f04f1a30175 Content-Type: text/plain; charset=UTF-8 On Wed, Feb 5, 2014 at 1:19 AM, Yasuo Ohgaki wrote: > Hi Dmitry, > > On Wed, Feb 5, 2014 at 3:30 AM, Dmitry Stogov 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 > --f46d044283b085a14f04f1a30175--