Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98761 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82631 invoked from network); 10 Apr 2017 20:23:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Apr 2017 20:23:29 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:57934] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/37-22499-DB9EBE85 for ; Mon, 10 Apr 2017 16:23:28 -0400 Received: (qmail 115366 invoked by uid 89); 10 Apr 2017 20:23:22 -0000 Received: from unknown (HELO mail-qk0-f171.google.com) (yohgaki@ohgaki.net@209.85.220.171) by 0 with ESMTPA; 10 Apr 2017 20:23:22 -0000 Received: by mail-qk0-f171.google.com with SMTP id p68so98437708qke.1 for ; Mon, 10 Apr 2017 13:23:22 -0700 (PDT) X-Gm-Message-State: AN3rC/48ULW66bcjpXm3qf7RoBxd5cs+9ZBxJ+Cf6hBt9nJRsJZ0PZoF8Say/MNg8l09pROTpavkpnUrfsh8eQ== X-Received: by 10.55.19.16 with SMTP id d16mr27073796qkh.142.1491855795675; Mon, 10 Apr 2017 13:23:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.101.109 with HTTP; Mon, 10 Apr 2017 13:22:35 -0700 (PDT) In-Reply-To: References: Date: Tue, 11 Apr 2017 05:22:35 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Rasmus Schultz Cc: PHP internals Content-Type: multipart/alternative; boundary=001a1144dc3cc1e843054cd5befc Subject: Re: [PHP-DEV] scalar type-casting From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1144dc3cc1e843054cd5befc Content-Type: text/plain; charset=UTF-8 Hi Rasmus, On Mon, Apr 10, 2017 at 5:18 PM, Rasmus Schultz wrote: > My concern is actually neither performance nor brevity - my concern is, > can you read the code and actually understand what it does, can you write > code without running into surprising side-effects, and so on. Users must not write code that has side effect, just like user must not do it with assert(). DbC has 2 main merits - ensure program correctness by pre/post conditions (and invariant) during development. - better performance and security. With DbC, it's easy to write and maintain _all_ "necessary and sufficient conditions" for _every_ functions/methods that makes sure program correctness. Unit Test can't achieve what DbC can. i.e. It is not feasible to write all "necessary and sufficient conditions" unit tests for every single functions/methods. invariant check is even more difficult. The most important DbC merit is "Ensured program correctness", then security. Performance would be the least important for PHP as you mentioned. P.S. DbC is not a Unit Test replacement. Unless there is Unit Test, pre/post/invariant conditions cannot be checked easily/repeatedly. -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1144dc3cc1e843054cd5befc--