Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72247 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57214 invoked from network); 5 Feb 2014 07:58:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2014 07:58:17 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.99 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.99 smtp99.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.99] ([108.166.43.99:51235] helo=smtp99.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/43-22810-81FE1F25 for ; Wed, 05 Feb 2014 02:58:16 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp5.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id EE2401B00D6; Wed, 5 Feb 2014 02:58:13 -0500 (EST) X-Virus-Scanned: OK Received: by smtp5.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id EB7BA1B0081; Wed, 5 Feb 2014 02:58:12 -0500 (EST) Message-ID: <52F1EF12.2050705@sugarcrm.com> Date: Tue, 04 Feb 2014 23:58:10 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Yasuo Ohgaki CC: PHP internals References: <52EE2B66.4040005@pthreads.org> <52F157BE.3020804@ajf.me> <52F15FD6.7060901@ajf.me> <52F1E58F.3050105@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RE: RFC: expectations/assertions From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > function func() {} > assert(func()); > > and > > assert(function func() {}); > > would be better to get the same result. Besides, rather than It won't be the same result, because first is a function call, and the second one is not even an expression in PHP, it's function definition. But if it were anonymous function, it would return function and not the result on the function call. > This form > > assert(function func() { > // some code here > }); You probably meant to write a closure (anonymous function) there. So you 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. > 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? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227