Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72239 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37063 invoked from network); 5 Feb 2014 06:21:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2014 06:21:56 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.174 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.174 mail-ob0-f174.google.com Received: from [209.85.214.174] ([209.85.214.174:41240] helo=mail-ob0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/60-22810-288D1F25 for ; Wed, 05 Feb 2014 01:21:55 -0500 Received: by mail-ob0-f174.google.com with SMTP id uy5so10740067obc.19 for ; Tue, 04 Feb 2014 22:21:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=2IqGsXSTm2PHtCg9wao5Lj2zv/ItMclrwyzbJG9RNtk=; b=h4miJakwQ7fjhZxmseOMRx1LyE5cFL2ZtHFErEf5slzbMOr2LBhNAhSf7b2nr9u8ND RXKsjYtWjcDxamEHPiNO9uYJR30AjokJSRmh283aPkevXZccOXGIUfpLj4rx4koulYx5 MFpIR3oD9FkGJIUALmohOdbC/gPXRx8ZrXvg2qI3zhPR6sKiM6h8MYjuQA4NDnuXQ2hl nvKPU1tO0S0a5IEbTEkUrJ1dk1dICFtiTdex7DXHmpP/vaeezOWjzYvazjqO3FasB7Iw g9bzx+0Fp5xRwTbMAcDUeOMmFEpX5ctdYdHOE+D6rFZC4J9nFtiAPe5SOshbms2T8OHk FbYw== MIME-Version: 1.0 X-Received: by 10.60.93.105 with SMTP id ct9mr39884182oeb.12.1391581311899; Tue, 04 Feb 2014 22:21:51 -0800 (PST) Received: by 10.182.54.112 with HTTP; Tue, 4 Feb 2014 22:21:51 -0800 (PST) In-Reply-To: References: <52EE2B66.4040005@pthreads.org> <52F157BE.3020804@ajf.me> <52F15FD6.7060901@ajf.me> Date: Wed, 5 Feb 2014 07:21:51 +0100 Message-ID: To: Yasuo Ohgaki Cc: Joe Watkins , PHP internals Content-Type: multipart/alternative; boundary=047d7b33d5a0c59f4704f1a2c5c6 Subject: Re: [PHP-DEV] RE: RFC: expectations/assertions From: nikita.ppv@gmail.com (Nikita Popov) --047d7b33d5a0c59f4704f1a2c5c6 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Feb 5, 2014 at 4:11 AM, Yasuo Ohgaki wrote: > Hi all, > > On Wed, Feb 5, 2014 at 7:53 AM, Yasuo Ohgaki wrote: > > > php > assert('function() {return FALSE;}'); > > php > assert('function() {return TRUE;}'); > > > > It does not work, but > > > > php > assert(eval('function() {return FALSE;};')); > > > > Warning: assert(): Assertion failed in php shell code on line 1 > > > > so closure in eval() works. I don't see reason not to allow closure > > directly. > > It only seems inconsistent to me. > > > > Added this to inconsistent behaviors RFC to track. > > https://wiki.php.net/rfc/inconsistent-behaviors#assert > 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(){})(). There is no inconsistency here. Allowing callables in general is not compatible with the existing string-eval mode and the expectation that arrays will assert true if they are non-empty. Adding only closures, *that* is inconsistent. Nikita --047d7b33d5a0c59f4704f1a2c5c6--