Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81971 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85027 invoked from network); 5 Feb 2015 23:01:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 23:01:54 -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.216.182 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.216.182 mail-qc0-f182.google.com Received: from [209.85.216.182] ([209.85.216.182:33692] helo=mail-qc0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/50-17766-166F3D45 for ; Thu, 05 Feb 2015 18:01:53 -0500 Received: by mail-qc0-f182.google.com with SMTP id l6so9038551qcy.13 for ; Thu, 05 Feb 2015 15:01:50 -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=Gcq5g2S1G2Lyu8IuGzuPfaCTccEcCUZ2QpFB6Ypabls=; b=odL8SIGgpo9mxbgVVSzdFLZeJ3aFtlreeJjPP3Re7INt7mTSRE5myGtezjfd/jZe6+ 54PJJA19bjVIganCrIP0WRAmBiSB0hf102r2seQyVG7eeDDqKYxoVfgAVbU4PKLiek4b Da7mH7yQdu/B1QzFCGPVgWbjH3cGh1hT88bJJS7QvnzBQG1e4dKlIjOKYRC41C/DT4xl MU7D+BFF30H2UKIYZsWg/ewCL1NrkYnb89HMAy1t6FsB8QW3wvhxgQUW++XlMTdcv9hN Sl+8I9AoBuRXpiT3LsyODYN3I0+96ZWl/DtghE2v5/djRdYEvG4a/uyRtqWH18t0uIqu ysMw== X-Received: by 10.224.28.198 with SMTP id n6mr1286358qac.15.1423177309992; Thu, 05 Feb 2015 15:01:49 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.28.72 with HTTP; Thu, 5 Feb 2015 15:01:08 -0800 (PST) In-Reply-To: References: <01d601d04146$6fbda4c0$4f38ee40$@tekwire.net> <020c01d0414b$2c3a1120$84ae3360$@tekwire.net> <023201d0415e$5731d800$05958800$@tekwire.net> Date: Fri, 6 Feb 2015 08:01:08 +0900 X-Google-Sender-Auth: 0zY_kjJxsa9icTfSiHQ68Sh6FlQ Message-ID: To: Dmitry Stogov Cc: =?UTF-8?Q?Fran=C3=A7ois_Laupretre?= , Pierre Joye , PHP internals Content-Type: multipart/alternative; boundary=001a11c2cc9a04a112050e5f4aac Subject: Re: [PHP-DEV] Design by Contract From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c2cc9a04a112050e5f4aac Content-Type: text/plain; charset=UTF-8 Hi Dmitry, On Fri, Feb 6, 2015 at 3:58 AM, Dmitry Stogov wrote: > I don't think we should chose "right" approach right now. > It's better to collect few possible solutions e.g. statements, > expressions, doc-comments, attributes... > then describe their pros and cons to select the best one > I agree. ensure($ret) {} is better than my original thought. I don't object to restrict pre/post conditions to expressions. require(is_numeric($a) && $a >= 0, "some error message") require(is_numerc($b) && $b >= 0, "another error message") this requires less lines and meaning is clear. For parsers other than PHP require { assert(is_numeric($a) && $a >= 0, "some error message") assert(is_numerc($b) && $b >= 0, "another error message") } may be a little easy to parse. Even if it is, it's marginal. Allowing any PHP syntax would require other parsers complex parsing. Those who would like to get pre/post conditions, it's time to think how it looks like including reflection. Restricting pre/post conditions to assert expressions may yield clean result. AST would be handy. Reflection is not too important, since pre/post conditions are for development. It may be okay to reflect existence of pre/post conditions. These conditions does not exists in production anyway. I'm not sure it's worth to support reflection. Rather than reflection, user space AST browser could be more useful. IMHO, E_WARNING is good enough. If anyone would like to 'throw' exceptions, it's time to think, too. These are my random thoughts. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c2cc9a04a112050e5f4aac--