Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72295 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75941 invoked from network); 5 Feb 2014 20:50:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2014 20:50:41 -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.169 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.169 mail-lb0-f169.google.com Received: from [209.85.217.169] ([209.85.217.169:35528] helo=mail-lb0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/67-38005-F14A2F25 for ; Wed, 05 Feb 2014 15:50:39 -0500 Received: by mail-lb0-f169.google.com with SMTP id q8so773578lbi.14 for ; Wed, 05 Feb 2014 12:50:36 -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=Zjs1G6SDqkPz15NzhgoImlWpgn3lR3YTMLhKi2e2MhQ=; b=HjCl22pGPvS4rF7MKSG/xVjh9LZPCbSlZ0zamBAVS3kHwMKFBfl98m6j8POqM9fW58 xhr1EOQfxoUNpbJcinrjRb1DvQKs066YFWQyrjxenJkHXh6RlXPwOG/TPRD9rjBJ1gTN J09J48DvXOg/Ya2BqXX60vuj1+MvXzg8n314XjhsMIyjvFCP7AoWBKraswzs8EnIld7u VNXzMIn6KZjTpGxj7huM8QSSHpb8NMUcKOPN42+M9iXVdZ8BqFMb86CD9Cd/k5xbJ/TG PfNiJwyQPZ8GP0DnAPuZZiRLz+29hxR9HdL6P1P3YIXWv4HtKe6YLa9jnmrwbkVFODyx YOTw== X-Received: by 10.152.219.97 with SMTP id pn1mr2522633lac.9.1391633436180; Wed, 05 Feb 2014 12:50:36 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Wed, 5 Feb 2014 12:49:55 -0800 (PST) In-Reply-To: <52F20D8B.9000003@gmail.com> 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> <52F20D8B.9000003@gmail.com> Date: Thu, 6 Feb 2014 05:49:55 +0900 X-Google-Sender-Auth: ypgeZQsozS0FuZbjoaTov1eQfC0 Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1137f67c9f058004f1aee8cd Subject: Re: [PHP-DEV] RE: RFC: expectations/assertions From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1137f67c9f058004f1aee8cd Content-Type: text/plain; charset=UTF-8 Hi Rowan, On Wed, Feb 5, 2014 at 7:08 PM, Rowan Collins wrote: > function foo($arg) > { > assert ( (function() use ($arg) { > $assert_private_var = some_function(); > return $arg == $assert_private_var; > })(), 'oops' ); > } > > Not pretty, but it would give you your local scope. > I agree, some thing like this is needed to call closure or pass arguments to assert() then call. It better than using scope. IMO. BTW, if we would like to write down all of assert() related code inside current assert(), it seems this works. It still pollutes scope, though. php > $v = 555; php > assert(($f = function($v) {var_dump($v);return $v < 0;}) && ($f($v))); int(555) Warning: assert(): Assertion failed in php shell code on line 1 This may be the way to use new assert. assert( ($f = function($v) { var_dump($v);return $v < 0; }) && ($f($v)), 'Do not pass bad value' ); It does not look good, but not too bad. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1137f67c9f058004f1aee8cd--