Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81950 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39631 invoked from network); 5 Feb 2015 17:40:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 17:40:28 -0000 Authentication-Results: pb1.pair.com header.from=francois@tekwire.net; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=francois@tekwire.net; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain tekwire.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@tekwire.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:47240] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/36-27691-A0BA3D45 for ; Thu, 05 Feb 2015 12:40:28 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id DAE344B02C1; Thu, 5 Feb 2015 18:37:04 +0100 (CET) Reply-To: To: "'Dmitry Stogov'" Cc: "'Yasuo Ohgaki'" , "'Pierre Joye'" , "'PHP internals'" References: <01d601d04146$6fbda4c0$4f38ee40$@tekwire.net> <020c01d0414b$2c3a1120$84ae3360$@tekwire.net> <023201d0415e$5731d800$05958800$@tekwire.net> In-Reply-To: Date: Thu, 5 Feb 2015 18:40:17 +0100 Message-ID: <025001d0416a$cf5c35d0$6e14a170$@tekwire.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQGgxP9HPTh52uHWkGo6jLSeXRdtNAIuYisqAXiAI4oCe0Gg3wHoiozGAesUmP8DLuqyBQEPGc/rnM+m5EA= Content-Language: fr X-Antivirus: avast! (VPS 150205-0, 05/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] Design by Contract From: francois@tekwire.net (=?utf-8?Q?Fran=C3=A7ois_Laupretre?=) De : Dmitry Stogov [mailto:dmitry@zend.com]=20 > > I don't like phpdoc approach because we have to define, parse and = compile new syntax for constraints. > Would constraint be able to call other functions? include external php = files? etc? There are 2 sort of constraints : - declared types with a specific, while very intuitive, syntax (support = for every current type found in phpdoc will be provided). These types = will be sent as plain strings along with the corresponding zval argument = to an internal validator function. This is a valuable addition compared = to the DbC basic conditions. I gave the example of str_replace() whose = search argument would have a type like 'string|array(string)'. Do you = think that, if we implement such a check in PHP in an in{} block, it = will be as readable ? I don't think so. OK, it is an addition to what = other languages implement but, if we implement something easier and more = readable, the concept is still valid. - and assertions. An assertion line just contains a PHP expression to = evaluate. No new syntax here, expression can do anything, like calling an external validator function. The condition = would be executed in the function scope, so it would have access to = anything accessible from the function body. Exactly the same as what we = would do with in/out{} blocks. In my opinion, as I previously explained, constraints shouldn't be = parsed by the PHP engine, but by a pre-processor which would run before = any other action takes place. This pre-processor would insert some PHP = code where it is needed. Then, the script would be compiled but the = engine doesn't have to be concerned. Cheers Fran=C3=A7ois