Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82330 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1885 invoked from network); 10 Feb 2015 06:16:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Feb 2015 06:16:13 -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.54 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.220.54 mail-pa0-f54.google.com Received: from [209.85.220.54] ([209.85.220.54:63633] helo=mail-pa0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/45-47508-722A9D45 for ; Tue, 10 Feb 2015 01:16:12 -0500 Received: by mail-pa0-f54.google.com with SMTP id kx10so23901611pab.13 for ; Mon, 09 Feb 2015 22:16:04 -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=5gOTg3RGfpcz2KyUW3x++DT3hfa6YXwl72dBsVdbrT8=; b=KeVSJq3TBuTLvTHnYzLSP0e2dBcxhUuM3zsHqGkDm25GfP/sy5qibKPqs1iWP0gM40 u271JAggWSdXpKrGCQ9u4eLObAFt5izjITvKFfF3u30frnJwnSMX5ZR4Kgd0fZEEw38J vMLMpH9mA3yab+qAs3exq+uIxMwkmbWD+gtbnnTOLR56npElixLWk6elruYZIHpUFnDJ hkMYWej89VLB7gxJjgXTcLLoMWnOGtNzuX/X5MlKDiOcj5l2UgzBbwHM7BRQjdrlo/4v GcakTWuv4zcKJf5LUBN7X7FabbbXRmBjB9iOhDFn4BdWK9IiNZeMbtbRLBV4o3ofvDdT 8OOw== X-Gm-Message-State: ALoCoQk0vnq1Gznx/MY9yAOILXeOoqElorDEx03+RYAWsLzw8l3jZFDPGFKCo/peOwhQTzm6g/UC MIME-Version: 1.0 X-Received: by 10.70.90.6 with SMTP id bs6mr34726624pdb.128.1423548964275; Mon, 09 Feb 2015 22:16:04 -0800 (PST) Received: by 10.70.49.100 with HTTP; Mon, 9 Feb 2015 22:16:03 -0800 (PST) X-Originating-IP: [109.145.22.92] In-Reply-To: References: <54D7ED22.3080001@gmail.com> Date: Tue, 10 Feb 2015 06:16:03 +0000 Message-ID: To: Yasuo Ohgaki Cc: Dmitry Stogov , =?UTF-8?Q?Fran=C3=A7ois_Laupretre?= , Stanislav Malyshev , PHP Internals Content-Type: multipart/alternative; boundary=001a11c222ea56204f050eb5d2a7 Subject: Re: [PHP-DEV] Design by Contract From: pthreads@pthreads.org (Joe Watkins) --001a11c222ea56204f050eb5d2a7 Content-Type: text/plain; charset=UTF-8 Morning, A good start ... ish ... Please steer clear of using the assert API, and in so doing avoid BC concerns with the current assert API. Please avoid adding a magic method and use the suggested syntax for invariant. class Some { require(invariant-expr); /* ... */ } like that is best I think ... You need to explain how invariants are going to be inherited and executed in detail. Keep statements such as > With proper use of DbC concept, it is known *programs to be more robust, secure and faster* Out of the RFC, since that cannot possibly be true and is just going to cause people to argue about that point when it's extremely unimportant. Cheers Joe On Mon, Feb 9, 2015 at 11:47 PM, Yasuo Ohgaki wrote: > Hi all, > > On Tue, Feb 10, 2015 at 5:27 AM, Yasuo Ohgaki wrote: > >> On Tue, Feb 10, 2015 at 5:19 AM, Yasuo Ohgaki wrote: >> >>> Use of interface: >>> - no additional keyword (pros) >>> - requires interface for DbC, most classes does not require interface >>> (cons) >>> - if interface is not used, user has to repeat invariant conditions >>> over and over (cons) >>> - requires to define method that should not exist in production (cons) >>> >>> New keyword: >>> - does not require interface for efficient definition (pros). >>> - new keyword (cons) >>> >>> It seems we are better to choose proper keyword for 'invariant'. >>> 'invariant' is not common, so 'invariant' >>> may be good enough choice. Does anyone use 'invariant' as >>> function/method/class/constant names? >>> If there is better name, suggestion is appreciated. >>> >> >> It might be be better to use special method. No keyword, use only >> reserved method name __func(). >> I'll write what I think that are better for PHP in the RFC. >> We may discuss anything here to complete the RFC. >> > > The RFC draft is ready. > https://wiki.php.net/rfc/dbc2 > > I think we might be better to use > > return($ret) { > assert($ret > 0); > } > > as the syntax. It doesn't look like definition, but code though. > > We may introduce $> or like as return value, but it looks like PERL. > It's not for me, but PHP stands for People Hate Perl for some. > > Any comments, corrections, improvements are appreciated. > If anyone could fix bad English, it would be great! > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > --001a11c222ea56204f050eb5d2a7--