Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72253 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77787 invoked from network); 5 Feb 2014 09:53:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2014 09:53:36 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.41 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.41 mail-la0-f41.google.com Received: from [209.85.215.41] ([209.85.215.41:57924] helo=mail-la0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/60-09402-E1A02F25 for ; Wed, 05 Feb 2014 04:53:34 -0500 Received: by mail-la0-f41.google.com with SMTP id mc6so125577lab.0 for ; Wed, 05 Feb 2014 01:53:31 -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=+/K3qivsHBkrGapZMv9+o6IPybeeH7ECYEDB2IJqc9U=; b=Fg7oVZVCZOaPPasDZiWMD0PSBWTV9ellYgn66KGIxrBCahCnrIds7o+ZUGU70RVnKS c+ZeVqHbsuF8D08qh5ZDm5qSHwxjdd2MSwrm0MJ9FbMCcnWVDopH9qGgXjurcW4nXIwz kmiGkxoIaCgjJtHCLfvHfNlBnUtLH2T5NorfbbpHHtJrwhazzoMj8o3E9/atIO9BjM7C WfKaeQy/wQbE0EIlxRdqqsQzDrDYMKitj3KjgrfjeaR6FQaqxIKQMqWcxnM+gNmd191w rWZ/tOhuGpg4IJH3z4EJdkYfRN4cBiJyazURpr7qeabk59SHK0YMTwPjdnGY/JQirOUd sHEw== X-Received: by 10.152.30.68 with SMTP id q4mr403472lah.44.1391594011112; Wed, 05 Feb 2014 01:53:31 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Wed, 5 Feb 2014 01:52:50 -0800 (PST) In-Reply-To: References: <52EE2B66.4040005@pthreads.org> <52F157BE.3020804@ajf.me> <52F15FD6.7060901@ajf.me> <52F1E58F.3050105@sugarcrm.com> <52F1EF12.2050705@sugarcrm.com> <52F1F675.2000600@sugarcrm.com> Date: Wed, 5 Feb 2014 18:52:50 +0900 X-Google-Sender-Auth: 05-UNdpKC9iXZS1nl9qv4fzZIoA Message-ID: To: Stas Malyshev , Dmitry Stogov , Joe Watkins Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0160b42cb43a9c04f1a5ba8c Subject: Re: [PHP-DEV] RE: RFC: expectations/assertions From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e0160b42cb43a9c04f1a5ba8c Content-Type: text/plain; charset=UTF-8 Hi Stas and all, On Wed, Feb 5, 2014 at 5:47 PM, Yasuo Ohgaki wrote: > On Wed, Feb 5, 2014 at 5:29 PM, Stas Malyshev wrote: > >> > 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. >> >> But I mean assert(). Javascript implementations have assert() - Chrome >> has it, Firefox has it, NodeJS has it. It does not work like you >> propose. Doesn't it make you question your assertion that Javascript >> users really need this? > > > I think it's nice to have as it does not use variable scope/name space. > Code related to assert() is better to hide it's existence as much as > possible. IMO. > > JavaScript implementations have different APIs. Node.js has closer API. > > assert.throws( > function() { > throw new Error("Wrong value"); > }, > Error > ); > > while we may have > > assert( > function() { > // Some check here > return FALSE; > }, > 'Error' > ); > > I would use at least, since I don't want to assert() related code to use > variable scope nor namespace. > Since I like new assert(), I thought it may help if I explain why I didn't use assertion. I have 2 reasons for not using old assert() at all until now. - Performance: couldn't accept run time overheads - Scope/Namespace: couldn't accept scope/namespace pollution with complex assert. 1st one is the main reason. 2nd one, I may live with it new assert(), but I do not want to pollute scope/namespace if it can. It does not make sense to use scope/namespace for assert() to me. (with complex assertion) Before the closure introduction, I had to define function. Without namespace, it's not a acceptable solution at all. Even with namespace, it's far from acceptable. Another option is create_function(), but it's pain to write PHP code as string. It's not acceptable also. Closure would be acceptable, but it's not clean as it should be w/o closure callback support. I cannot wait to use new assert(). If it supports closure callback, it's PERFECT! I'm really excited about new assert() and I wish desperately it supports closure callback. Please add closure callback :) Thank you! -- Yasuo Ohgaki yohgaki@ohgaki.net --089e0160b42cb43a9c04f1a5ba8c--