Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72283 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47671 invoked from network); 5 Feb 2014 17:40:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2014 17:40:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=william.a.bartlett@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=william.a.bartlett@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.41 as permitted sender) X-PHP-List-Original-Sender: william.a.bartlett@gmail.com X-Host-Fingerprint: 209.85.219.41 mail-oa0-f41.google.com Received: from [209.85.219.41] ([209.85.219.41:56412] helo=mail-oa0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/C1-38005-E7772F25 for ; Wed, 05 Feb 2014 12:40:14 -0500 Received: by mail-oa0-f41.google.com with SMTP id j17so871493oag.28 for ; Wed, 05 Feb 2014 09:40:11 -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=Ca3dwSz+teGjzfZiu/4NoC3kaCjFcUFtcJt4pOEColY=; b=bSWo0X0csPTgLo/Ccrf/YuIFDqpD5EB6ssyBg1KNTN4gCmu9+vsX9t8GGM7jZvONtz e4HaT3YqdCFTZT5D2hFCqIYAS4+5tHsiFYERMX0N//pmc3sWs6M8YKaA5JeuZdlrwx7p INonPR9v00SIjnMo+26HjPgsSz7jn3DfX+pj7OmisqGGENPGT52eKCvMV0+TYCvvdi/0 jYupk9YKaA5Ynev/MelkDUvmSaHjlFCliqBKJk+TPVV1OnGAMpBsF3DzvAR2mIrZG+vX 2aB9fpuEfiwDvaQjyVOfN6ESDolzmRjf0L8cIcyl2od7RI+0dG6q+yD3ckbpqDaFT2/F zYdg== MIME-Version: 1.0 X-Received: by 10.182.135.165 with SMTP id pt5mr2532248obb.66.1391622011504; Wed, 05 Feb 2014 09:40:11 -0800 (PST) Received: by 10.60.161.38 with HTTP; Wed, 5 Feb 2014 09:40:11 -0800 (PST) In-Reply-To: References: <52EF4BF8.60005@sugarcrm.com> Date: Wed, 5 Feb 2014 12:40:11 -0500 Message-ID: To: Yasuo Ohgaki Cc: Dmitry Stogov , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0112cb9ea84fc504f1ac3f81 Subject: Re: [PHP-DEV] Declare minimum PHP version required? From: william.a.bartlett@gmail.com (William Bartlett) --089e0112cb9ea84fc504f1ac3f81 Content-Type: text/plain; charset=ISO-8859-1 I'm not a frequent contributor on internals but I think a little something is being missed here. Passing callable instead of boolean (or something that converts to boolean) is the altnerate way of making asserts fast without making them a language construct (in other programming languages). Showing by example. Forget about language construct assert and assuming its simply a function. Example 1: assert takes boolean $func = function(){ /* stuff */ } assert(func()) in dev and production environments, func() is evaluated before assert is called. Example 2: assert takes callable $func = function(){ /* stuff */} assert(func) In dev environments, assert calls func, but in production environments, assert returns immediately and func is never called. My understanding is that adding language level constructs adds overhead to the language as a whole. In my mind, assert taking callable should be an ALTERNATIVE to assert as a language level construct. Thanks and lemme know if I'm misunderstanding, Will Bartlett -- William Bartlett College of Engineering | Cornell University '14 240-432-5189 On Wed, Feb 5, 2014 at 2:21 AM, Yasuo Ohgaki wrote: > Hi Dmitry, > > On Wed, Feb 5, 2014 at 3:38 PM, Dmitry Stogov wrote: > > > but we can write: > > > > $f = function() {return FALSE;}; > > assert($f()); > > > > I'll use this form, if assert() does not support direct closure call. > Direct call seems cleaner to me. > > assert(function() { > // Do complex assertion here. > }; > > Users are used to this form because of JavaScript popularity. > It's a small difference, but I hope new assert() supports this :) > > Regards, > > P.S. Thank you for the declare(pre/post_hook) comment. I'll look > into VM when I have time. > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > --089e0112cb9ea84fc504f1ac3f81--