Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72249 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61630 invoked from network); 5 Feb 2014 08:13:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2014 08:13:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.181 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.181 mail-lb0-f181.google.com Received: from [209.85.217.181] ([209.85.217.181:44464] helo=mail-lb0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/04-22810-592F1F25 for ; Wed, 05 Feb 2014 03:13:10 -0500 Received: by mail-lb0-f181.google.com with SMTP id z5so42927lbh.12 for ; Wed, 05 Feb 2014 00:13:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=DR7H9eqYl12uBwEsGZNXH4GxIolzmm7snfxyMwlw0OA=; b=dIogCG9lA/shlCQpR0J/CxUXvw+oCZx4gUjRMWjlqfRKKNpA8yl0uz0gF6qaWNvEOd vSc+TM3LJL54AeLXj3RwTWiHvhFbvQAtHd2wEv58ZVCKjyYB4A55TKgbfC5v2a8aFNdo aHPM5qbFf8dbd3PGgaXZvAagC38c7vPFsGM7X7kF4JtQm2gA3DXAPoPsvxB0lu+PSTLt WRWCN0glBqRsXs6h9RTlo6JpYG9KeTYtCuyTMlfh/REoYFh2I6Azd+/f5DYaF1tkrRkd zcn5/ZEUluzauIzftng7ZnclT+4pfBbkYlDv1ue27gIYBYWf3+ikF6/e1nMrt3gJpHZ4 xIhA== X-Received: by 10.152.1.130 with SMTP id 2mr78016lam.88.1391587986292; Wed, 05 Feb 2014 00:13:06 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Wed, 5 Feb 2014 00:12:25 -0800 (PST) In-Reply-To: <52F1EF12.2050705@sugarcrm.com> References: <52EE2B66.4040005@pthreads.org> <52F157BE.3020804@ajf.me> <52F15FD6.7060901@ajf.me> <52F1E58F.3050105@sugarcrm.com> <52F1EF12.2050705@sugarcrm.com> Date: Wed, 5 Feb 2014 17:12:25 +0900 X-Google-Sender-Auth: Hf_2dmN3sZhmHYmPycVXOerJyjg Message-ID: To: Stas Malyshev Cc: PHP internals Content-Type: multipart/alternative; boundary=089e013c674e98c53904f1a45341 Subject: Re: [PHP-DEV] RE: RFC: expectations/assertions From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e013c674e98c53904f1a45341 Content-Type: text/plain; charset=UTF-8 Hi Stas, On Wed, Feb 5, 2014 at 4:58 PM, Stas Malyshev wrote: > > This form > > > > assert(function func() { > > // some code here > > }); > > You probably meant to write a closure (anonymous function) there. So you > Yes. > actually want assert to support calling closures. This would be a BC > break, but it is very easy to make your own assert that does just that. > If we allow any callable, it's would be BC break since callable could be string (function name). > > > I'm sure most users are used to latter form, since this form > > is used extensively in JavaScript. It keeps variable scope > > clean, too. > > No users of PHP are used to this form since this form does not exist in > PHP. As for Javascript users, there's no assert in standards, but many > browsers support console.assert - which works exactly like PHP assert > (without eval stuff) and does not support calling closures either. > See e.g. http://stackoverflow.com/q/15313418/214196 > So I wonder how Javascript users would get used to that I meant the form of the code, not assert(). JavaScript uses callbacks extensively and users are used to it. PHP users are also getting used to it since the introduction of closure. If we are going to support closure only callback, then everything is ok for assert() to call closure, I suppose. Sorry that I wrote the same thing 3 times in this thread, but assert(function() { // some code }); would keep variable scope/name space clean when user would like to use call back. $f = function f() {}; assert($f()); OR function f() {} assert(f()); I think it's nice to have clean variable scope/name space with assert(). Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --089e013c674e98c53904f1a45341--