Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82352 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47004 invoked from network); 10 Feb 2015 08:49:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Feb 2015 08:49:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 209.85.192.179 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.192.179 mail-pd0-f179.google.com Received: from [209.85.192.179] ([209.85.192.179:46962] helo=mail-pd0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/9D-47508-916C9D45 for ; Tue, 10 Feb 2015 03:49:29 -0500 Received: by pdjy10 with SMTP id y10so7044528pdj.13 for ; Tue, 10 Feb 2015 00:49:26 -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=jxOmyVSdj+lW+GXVxZXnxDXyorzRDsGidgh9qmIVMiM=; b=gHK3lvR2old0QWGC/5ylT3kf2RyMkn65WQo6Y7OJ963GFuKWogJnamPxZB0YQ8MM0q 6LzmdS1TuQN4HsthRD+jFyRbhr4L5OgbthY/2gt5GUkQlgWyr55UbrieiazPpWmtjuaz QeQyHPY3dT4cWpHmtUInaMaWZf29KS8yrtFYb04jD2D6bIlWhFRPGZbSqiv8gDxgH4Zq RlVq6UW00U84lkL0teFEal1OkIG3rxpvLjSYNW3RMVJFCyyaIIFP9CgYUa5rHcTVUcMz mnZ0T21BHebL7uTamU171sF8yITXCAzKU7T4zRaPxoO7OGtby+gN37XTIHOMB4Ttuin8 CMAQ== X-Gm-Message-State: ALoCoQnxOysxYm2yT64NeYV3cRJqrcfqKugvYcm70BGO5BpLJ7OmlJ796DY/ah69ZuJsD75D1B+D MIME-Version: 1.0 X-Received: by 10.66.146.168 with SMTP id td8mr35673481pab.20.1423558166745; Tue, 10 Feb 2015 00:49:26 -0800 (PST) Received: by 10.70.49.100 with HTTP; Tue, 10 Feb 2015 00:49:26 -0800 (PST) X-Originating-IP: [109.145.22.92] In-Reply-To: References: <54D7ED22.3080001@gmail.com> Date: Tue, 10 Feb 2015 08:49:26 +0000 Message-ID: To: Dmitry Stogov Cc: Yasuo Ohgaki , Patrick Schaaf , internals Content-Type: multipart/alternative; boundary=047d7b677884d8aa09050eb7f6f1 Subject: Re: [PHP-DEV] Design by Contract From: pthreads@pthreads.org (Joe Watkins) --047d7b677884d8aa09050eb7f6f1 Content-Type: text/plain; charset=UTF-8 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 >>>> >>> >>> >> > --047d7b677884d8aa09050eb7f6f1--