Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82347 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36073 invoked from network); 10 Feb 2015 07:40:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Feb 2015 07:40:21 -0000 Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 209.85.220.53 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.220.53 mail-pa0-f53.google.com Received: from [209.85.220.53] ([209.85.220.53:37927] helo=mail-pa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/AB-47508-5E5B9D45 for ; Tue, 10 Feb 2015 02:40:21 -0500 Received: by mail-pa0-f53.google.com with SMTP id lf10so31938801pab.12 for ; Mon, 09 Feb 2015 23:40:18 -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=zOMNYvHrBqJ+KVcMTlUkOR6Mz58UAHqPgkSp84LBE9E=; b=bHBF5rIYM31/P2hm4DKJ+Ekx672oOXOekNRYSMwQ+w25qkCT6Me09hqjoGHKZh+hKA uIxIHJnFXAizgRa6KKm98OSnNixDk2nmEp+ujNfOG0TuhK2FF3JCYHR2/cA8TqMaiJV5 VQs1LUX/u/KUkFAUeeYh5MkfrvYt1cak9YoAoNjE+2doKLybkmXzNr5WFyVNKSVpcn4f +QfEHhzGw1SrmI02wjZ4GgwDXnCcIIQI1dQVj7st4wZLIS3cq0uzFOrYjlmuu3QTDrLu yH24Y9+7bjjV4BeiM88YS4VY2QrLXruLBf2ZHmQF6aW8gYvzEc8Cb9dTB59kg9CNqo8s GumA== X-Gm-Message-State: ALoCoQmf2SPCvS/DShztZDn0ThxYb1bvX0siyeGvFStLw4y3utmML3xSXmnYCoqI2l3JAlS3SkLB MIME-Version: 1.0 X-Received: by 10.68.130.66 with SMTP id oc2mr35893146pbb.134.1423554018747; Mon, 09 Feb 2015 23:40:18 -0800 (PST) Received: by 10.70.49.100 with HTTP; Mon, 9 Feb 2015 23:40:18 -0800 (PST) X-Originating-IP: [109.145.22.92] In-Reply-To: References: <54D7ED22.3080001@gmail.com> Date: Tue, 10 Feb 2015 07:40:18 +0000 Message-ID: To: Yasuo Ohgaki Cc: Dmitry Stogov , Patrick Schaaf , internals Content-Type: multipart/alternative; boundary=047d7b10cc359b4dd9050eb6ffe0 Subject: Re: [PHP-DEV] Design by Contract From: pthreads@pthreads.org (Joe Watkins) --047d7b10cc359b4dd9050eb6ffe0 Content-Type: text/plain; charset=UTF-8 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 > --047d7b10cc359b4dd9050eb6ffe0--