Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82446 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63249 invoked from network); 11 Feb 2015 07:59:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Feb 2015 07:59:03 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.47 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.47 mail-pa0-f47.google.com Received: from [209.85.220.47] ([209.85.220.47:33256] helo=mail-pa0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DB/0D-33902-6CB0BD45 for ; Wed, 11 Feb 2015 02:59:02 -0500 Received: by mail-pa0-f47.google.com with SMTP id lf10so2412843pab.6 for ; Tue, 10 Feb 2015 23:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=mYNy0F+zs2LgAxXKhpLTdsJu0qDRzCmVqHlfy6Kdtko=; b=IQ4DwClCa/49F2xTHgY9DTZ32RX78AdP3he9ZjKSbT9oTd//OWRBuaXLdrZGIf8WoR d5AClMzkno372/e250k7F5eiEHkYWCEEAfwCjPVKmT0h3v4A4/njJRkcROUcS5uqecyJ ioO0K5zocsx3Dv6TuQDg27uJcN7QxYPex12gDo6uzQ+Om8scW8VJhGzhWYHESTjyfHy1 zD0diB4C0gCF68qg2mWf9GPtaIS1opidBrjBe0ddv1miAoApcy6fRZ/I6pQeCIw6WnB9 iZoNj8EjGxZM3EIeEGu2SoR94OChTDpos1R5AfnVevV56NLPlviLFYn8mCWTgnJBTjCF yqFQ== X-Received: by 10.70.140.200 with SMTP id ri8mr44129364pdb.165.1423641539470; Tue, 10 Feb 2015 23:58:59 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id dg5sm34361pbb.67.2015.02.10.23.58.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Feb 2015 23:58:58 -0800 (PST) Message-ID: <54DB0BC0.20304@gmail.com> Date: Tue, 10 Feb 2015 23:58:56 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Dmitry Stogov CC: Joe Watkins , Yasuo Ohgaki , =?UTF-8?B?RnJhbsOnb2lzIExhdXByZXRyZQ==?= , PHP Internals References: <54DAFD32.3000005@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Design by Contract From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > 1) contracts in doc-commetns https://wiki.php.net/rfc/dbc > > /** > * @requires ($a >= 0) > */ > function foo($a) { > } We've spent several years rejecting annotations because no information can be in comments, not even a little bit, not even a tiny. Now we'd have full-blown running code in comments? How would this code be debugged/profiled/interpreted by tools? Writing PHP parser is not easy right now, but this would turn it into nightmare (what if you have a comment inside @requires? etc.) > 2) contracts as part of the language https://wiki.php.net/rfc/dbc2 > > function foo($a) > require($a >= 0) > { > } This is a step better but still we have the similar issues with readability, to which reuse of 'require' is added. > 3) contracts in annotations > > <= 0)>> > function foo($a) { > } That one actually looks better to me, but: I'm not sure how annotation syntax is supposed to support expressions or closures, yet more - how it is supposed to share the scope with the function. I.e., if you define annotation class/method/function/data structure/whatever it is, what it is supposed to receive? Is it some special form of annotation for this purpose only (meh)? Oh, and <<>> syntax is *ugly* ;) -- Stas Malyshev smalyshev@gmail.com