Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82243 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79413 invoked from network); 9 Feb 2015 08:44:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2015 08:44:33 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.171 mail-vc0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:53184] helo=mail-vc0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/A5-50460-07378D45 for ; Mon, 09 Feb 2015 03:44:33 -0500 Received: by mail-vc0-f171.google.com with SMTP id kv19so2446597vcb.2 for ; Mon, 09 Feb 2015 00:44:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=9zPrks6SowS7tbS2qaa5QNBhkdw9cKrDXQINv6nrz4c=; b=Zdvo4JWPnRaWJ03EpFHBPDQKRpTunssvOoS7I6+YAtwVysMXGbeBfsy0RbupcqJxQA hiD3IYJwpPSf8Y3H7Qbcbpjqw09KRVSzg8xf03ttxK6hMs33STImczdwrNGwTh2nEXq5 SdwSXeN+6D3md5vm4raYqfPWtpdgGWCeqmQXv2ZHW8f/eXgG/Z2zP1pCaVJCmH5e4AG2 scfamsSYSSdyuU9RWjcefTM8l9KWrDCi80a4V48PVRZwuwCoJyvq5vJVCTwwqS9OUPEF 0MhcEKMHBzCG45w96x4+oahjXQPki84y3dsRvd7csNXpRBkY0PdpKbCawAGk3FH4Rw+y jYzg== X-Gm-Message-State: ALoCoQn/DwID5Ur2igNapmbeTVe7VdFN1urn8g4rnJtycNDsrz+Qvg0CyrdDIoX4Tydsi4HvJgZ/vHkYAD8A+1Xb9bd9mN3qJSdHajrm8ud749MuYex9eh98Nd22Uy2cJ2Rga4aPXsJx3yMs79XgqpI7L7fkuvubKg== MIME-Version: 1.0 X-Received: by 10.52.139.7 with SMTP id qu7mr7949988vdb.68.1423471469741; Mon, 09 Feb 2015 00:44:29 -0800 (PST) Received: by 10.52.74.73 with HTTP; Mon, 9 Feb 2015 00:44:29 -0800 (PST) In-Reply-To: <54D7ED22.3080001@gmail.com> References: <54D7ED22.3080001@gmail.com> Date: Mon, 9 Feb 2015 12:44:29 +0400 Message-ID: To: Stanislav Malyshev Cc: Yasuo Ohgaki , PHP Internals Content-Type: multipart/alternative; boundary=bcaec52d53ab4d5f49050ea3c75b Subject: Re: [PHP-DEV] Design by Contract From: dmitry@zend.com (Dmitry Stogov) --bcaec52d53ab4d5f49050ea3c75b Content-Type: text/plain; charset=UTF-8 It's nothing wrong here. It's just a concept that cares about constraints definition more. So, DbC with asserts spread among the code is like OOP without classes. Thanks. Dmitry. On Mon, Feb 9, 2015 at 2:11 AM, Stanislav Malyshev wrote: > Hi! > > > 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. > -- > Stas Malyshev > smalyshev@gmail.com > --bcaec52d53ab4d5f49050ea3c75b--