Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82208 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9785 invoked from network); 9 Feb 2015 01:23:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2015 01:23:15 -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.192.44 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.192.44 mail-qg0-f44.google.com Received: from [209.85.192.44] ([209.85.192.44:37619] helo=mail-qg0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DB/90-26926-10C08D45 for ; Sun, 08 Feb 2015 20:23:14 -0500 Received: by mail-qg0-f44.google.com with SMTP id j5so3977699qga.3 for ; Sun, 08 Feb 2015 17:23:10 -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=UsYqbkMQ0EipZaYwnzAAAUixM8OAj5wcxl9WBXsD2As=; b=Cwllo3K3AalvVBPNR5ECFSXq/vgUbHcl7PALT4Fvf9uiuA1cVaX4RaafyOsXTYB2Wt z8ZsLAnrVdRjXmhIbRyN+k59H5xzJJ5KKEnR1iUrzMcjTOSkUEZcfd+mf0byWwC5VDBV /3OKKXLDC/54NRJK6jr1kCmarVhkUtvpBXChBCeRjnqr4YWWQpl50nEgNME6HTdzP2rJ 2WrRjEITh8GKGaGp4gGh31tRiALwj0yezFtB45mFsqG0xyKVKqROhjoVOx+i/IAuphh0 h2oa7PLc49SshynrEDKk9Oanh37MfMiyQCDfNi7GdiKpjV5HVUGQVB6LafCZpZRfUjdU m+hQ== X-Received: by 10.224.38.70 with SMTP id a6mr7345573qae.15.1423444990841; Sun, 08 Feb 2015 17:23:10 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.28.72 with HTTP; Sun, 8 Feb 2015 17:22:29 -0800 (PST) In-Reply-To: <54D7ED22.3080001@gmail.com> References: <54D7ED22.3080001@gmail.com> Date: Mon, 9 Feb 2015 10:22:29 +0900 X-Google-Sender-Auth: NcXA66KrcmzXq9z7E4JagVgiSz8 Message-ID: To: Stanislav Malyshev Cc: Dmitry Stogov , PHP Internals Content-Type: multipart/alternative; boundary=001a11c2d274095b55050e9d9d2c Subject: Re: [PHP-DEV] Design by Contract From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c2d274095b55050e9d9d2c Content-Type: text/plain; charset=UTF-8 Hi Stas, On Mon, Feb 9, 2015 at 8:11 AM, Stanislav Malyshev wrote: > > Following our conversation, I tried to imagine how DbC should look like > in > > PHP from user perspective. Finally, I was influenced by the semantic > > proposed in D, and syntax proposed for Java. So, these are my initial > > thoughts: > > > > For php it may look like the following: > > > > function foo() > > requre() > > ensure() > > { > > ... > > } > > Why not do it simpler? > > function foo() { > // require > assert(); > ... > // ensure > assert(); > } > > I'm oversimplifying a bit, but in general, why we need more places to > have code in the function than the actual code of the function? It would > be harder to parse, to read, to maintain, to debug, to profile, etc. and > I'm not sure what exactly it provides that can't be done by plain > regular code inside the function. > > If we're concerned about the costs of assert, we could make special > provision in the compiler for zero-cost asserts. It doesn't require > moving code out of the function. Interesting idea. I like it. The only draw back I can see now is that this may make post/pre condition retrieving harder for automatic documentation. We may think of solution for this. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c2d274095b55050e9d9d2c--