Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82430 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38594 invoked from network); 11 Feb 2015 07:16:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Feb 2015 07:16:32 -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.220.48 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.220.48 mail-pa0-f48.google.com Received: from [209.85.220.48] ([209.85.220.48:63832] helo=mail-pa0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/97-33902-DC10BD45 for ; Wed, 11 Feb 2015 02:16:31 -0500 Received: by mail-pa0-f48.google.com with SMTP id eu11so2192389pac.7 for ; Tue, 10 Feb 2015 23:16: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=SaMF7eDmH3AhP4KzIbybC1NvyYdww5yOxgVkWQdNqW4=; b=H57Q5OeCwQl4PraXu793kt21hQiDQI2eufW3JpUWXUsZhGm5AdaAsNcaL5turLo+Ti /TNSTo+jUUx/VUoVB86Q/zT+MhSF8PnLdIDnugGDmNTGohkjx5TENbO4B9sUAmCvnnuC C17SLPMLgOZhbS4pCZBY13lyOsYAtlDz5V2fvwQhe5npcJLjl6ElMFmgy9fJfwPiEmUq FPdC+50ZYH/X3/wPFDlueWhCwkIfTXBR143PCNqrM96fWHm0tMI92EC7obsUqPIQMOPj 4BKwHNijxQ+mXkBcakAS2vzxUxoq3EAyl8TjEnZ6S0PpR3nkcOZ+fySOFvjVGI2Vc2bd +CWQ== X-Gm-Message-State: ALoCoQkqdHYFCrzati8lCX6mC77urGOD4M+RZrt6D+XVZpDBe5yX7hywgJCiXAARGQSqacAaMkRG MIME-Version: 1.0 X-Received: by 10.68.106.226 with SMTP id gx2mr44620016pbb.78.1423638986869; Tue, 10 Feb 2015 23:16:26 -0800 (PST) Received: by 10.70.49.100 with HTTP; Tue, 10 Feb 2015 23:16:26 -0800 (PST) X-Originating-IP: [109.145.22.92] In-Reply-To: References: <54D7ED22.3080001@gmail.com> <54DAFD32.3000005@gmail.com> Date: Wed, 11 Feb 2015 07:16:26 +0000 Message-ID: To: Stanislav Malyshev Cc: Yasuo Ohgaki , Dmitry Stogov , =?UTF-8?Q?Fran=C3=A7ois_Laupretre?= , PHP Internals Content-Type: multipart/alternative; boundary=047d7b6da9f01a08a4050ecac870 Subject: Re: [PHP-DEV] Design by Contract From: pthreads@pthreads.org (Joe Watkins) --047d7b6da9f01a08a4050ecac870 Content-Type: text/plain; charset=UTF-8 > I still don't see what's wrong with just putting the code at the beginning of the function and whenever you want to check it That makes inheritance of contracts awkward/impossible/impractical: class Some { public function method() { assertOrWhatever($expr); } } class Other extends Some { public function method() { } } The implementation of Other::method cannot inherit or otherwise make use of the contracts made by Some. Putting invariants in the class scope and pre/post conditions in the function prototype makes inheritance relatively easy. This seems to answer all your questions. Cheers Joe On Wed, Feb 11, 2015 at 7:11 AM, Joe Watkins wrote: > > I think reusing syntax for existing operator in completely unrelated > context is a big mistake. > > I keep hearing that, I agree, but adding keywords presents it's own > problems. > > The keywords can always be changed, maybe they can be a voting option even. > > Cheers > Joe > > On Wed, Feb 11, 2015 at 6:56 AM, Stanislav Malyshev > wrote: > >> Hi! >> >> > Please steer clear of using the assert API, and in so doing avoid BC >> > concerns with the current assert API. >> >> The operator can be called something other than "assert", I'm sure the >> thesaurus has a lot of possibilities. >> >> > Please avoid adding a magic method and use the suggested syntax for >> > invariant. >> > >> > class Some { >> > require(invariant-expr); >> >> I think reusing syntax for existing operator in completely unrelated >> context is a big mistake. Having code outside of functions is probably >> not the best idea too. >> >> -- >> Stas Malyshev >> smalyshev@gmail.com >> > > --047d7b6da9f01a08a4050ecac870--