Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82368 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85721 invoked from network); 10 Feb 2015 11:53:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Feb 2015 11:53:38 -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.182 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.182 mail-vc0-f182.google.com Received: from [209.85.220.182] ([209.85.220.182:40951] helo=mail-vc0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/05-47508-141F9D45 for ; Tue, 10 Feb 2015 06:53:37 -0500 Received: by mail-vc0-f182.google.com with SMTP id id10so5863206vcb.13 for ; Tue, 10 Feb 2015 03:53:35 -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=gq2ZYXgb9675WOigHSBpGM1Lq7JFv7WSn//ioEDHyFY=; b=X6FOEQU6uTpWyfQ8uOdQr21WJV0YtC8YVUnvP45psnSVaxppXXzs8U4EYqvEdjbDjE 0U+2looMifKx+N9Cb3Gu4fT5MdbjNYlbmxAMRWAoyD4M5UrGEJTrN0dLvYmR5QN5aAN2 pZpdvzaJQzglDFXL2yYkgPCRxXqDRlLONwesdfcW9ZhA9iy4wKQeZTjfH56z5tw8McsD rhWb+6PB4zKVUvybEOqqkP7XSZvThbksigmyFnpTo1/wus13XSDaqncOxDz3mJy4k+wC HPdVEdsdu+1XE0cRivrcgUPJwQ0W7jcvLLg3t4U2vPortxjbqClBpIq4OEu29asrFkZF 09Fw== X-Gm-Message-State: ALoCoQlmIFDICSwRUO3HxLRjpfk1oOZEOzF6SAVdFLL44IAz3Hoq6MBucXcurclqBqzhjImLdfzU9R4ZV25nVS3NBFjymRVOAGXmgMfVhUhjwBi28YzzynSvTC4eXcj769jTi4x8SLtXbXwF2Bb8tmYC5CU6dBI1kQ== MIME-Version: 1.0 X-Received: by 10.52.26.18 with SMTP id h18mr11581978vdg.51.1423569214867; Tue, 10 Feb 2015 03:53:34 -0800 (PST) Received: by 10.52.74.73 with HTTP; Tue, 10 Feb 2015 03:53:34 -0800 (PST) In-Reply-To: References: <54D7ED22.3080001@gmail.com> Date: Tue, 10 Feb 2015 15:53:34 +0400 Message-ID: To: Joe Watkins Cc: Yasuo Ohgaki , Patrick Schaaf , internals Content-Type: multipart/alternative; boundary=20cf307d00765da046050eba8932 Subject: Re: [PHP-DEV] Design by Contract From: dmitry@zend.com (Dmitry Stogov) --20cf307d00765da046050eba8932 Content-Type: text/plain; charset=UTF-8 Hi Joe, You are welcome to edit https://wiki.php.net/rfc/dbc2 It looks like we have similar views, so just make it better in a way you think. Thanks. Dmitry. On Tue, Feb 10, 2015 at 11:49 AM, Joe Watkins wrote: > I'm happy to clean up the RFC after Dmitry's changes are merged. > > Happy to author some of the content if Yasuo is busy or wants help ? > > Cheers > Joe > > > On Tue, Feb 10, 2015 at 8:29 AM, Dmitry Stogov wrote: > >> A bit updated version of RFC is attached. >> As I removed more than added, I decided not to put it on wiki before >> internal agreement. >> Actually, I would also remove most part of introduction as well, to make >> RFC more compact and clean. >> >> I cnahged $> into $ret, because $> just won't work. Some better solution >> is welcome. >> >> The RFC misses contract inheritance rules. They must be defined >> separately for preconditions, postconditions and invariants. >> Yasuo, could you please check, how it's implemented in D and add missing >> section. >> >> We will need English correction after all. >> >> Thanks. Dmitry. >> >> On Tue, Feb 10, 2015 at 11:19 AM, Dmitry Stogov wrote: >> >>> completely agree. contracts must be permanent. >>> >>> Thanks. Dmitry. >>> >>> On Tue, Feb 10, 2015 at 10:40 AM, Joe Watkins >>> wrote: >>> >>>> Example code never works, I can just say that's a bad abstraction, >>>> vertebrate and invertebrate are distinct and abstraction should reflect >>>> that. >>>> >>>> Why should we provide a way to change contracts is the question ? >>>> >>>> It doesn't seem to make sense to do that, a derived class should be >>>> able to define additional contracts, but not change the contracts of it's >>>> parent. >>>> >>>> Cheers >>>> Joe >>>> >>>> On Tue, Feb 10, 2015 at 7:36 AM, Yasuo Ohgaki >>>> wrote: >>>> >>>>> Hi Joe, >>>>> >>>>> On Tue, Feb 10, 2015 at 4:31 PM, Joe Watkins >>>>> wrote: >>>>> >>>>>> Actually I'm not sure it's at all sane to try to override contracts, >>>>>> I'd actually avoid that completely, so no need to name contracts and no >>>>>> need for magic __invariant. >>>>> >>>>> >>>>> For example, >>>>> >>>>> class Animal { >>>>> protected $legs; >>>>> require($legs >= 0); >>>>> } >>>>> >>>>> class Snake extends Animal { >>>>> // Snake is fine, no leg >>>>> } >>>>> >>>>> class Human extends Animal { >>>>> // 2 legs. $this->leg === 2 >>>>> } >>>>> >>>>> Overriding makes sense for many cases. >>>>> >>>>> Regards, >>>>> >>>>> -- >>>>> Yasuo Ohgaki >>>>> yohgaki@ohgaki.net >>>>> >>>> >>>> >>> >> > --20cf307d00765da046050eba8932--