Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81777 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44955 invoked from network); 4 Feb 2015 07:25:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2015 07:25:10 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.179 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.179 mail-vc0-f179.google.com Received: from [209.85.220.179] ([209.85.220.179:64484] helo=mail-vc0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7D/B7-20608-559C1D45 for ; Wed, 04 Feb 2015 02:25:10 -0500 Received: by mail-vc0-f179.google.com with SMTP id la4so18512066vcb.10 for ; Tue, 03 Feb 2015 23:25:06 -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=P+ulEzdIlDPO//d8bkZW5yfoMoCtUApMLbPu1K6Yqqk=; b=QGAAYrjM+bQxYdnFIaQLzK/aZyKNhsSj7LId/wxmIyDgGMVZJ2iJkS5JkxaO+2lPMH xWrWCMWHx+rEUJMultkKDr4oTlJI7mqxqFBlzMKM0q56XSfxjOixpzpSjBXD6NdH05bz mwF2JRxjTCC3KTWpOozBUqw7yQ2Dk85LsI9QiIeLd05FB3QzBif+5aOUVuEPi2i2apwl 52x6sKNezwhWPsO3EfiODck28O3ZyABb3hHMB/8Bl7ie+BOXHhPSxgRlmm/LMiWsYcGG E+uadrkwkwb9uqXxKCtE/KpJj5CmRdqN9glX11RpD1d/C5xuCdyVw6eU2XOmFfYEx5NI +nXw== X-Gm-Message-State: ALoCoQnttxkC/gVUHBW5iUBLxC8Azx/sYLDiscAq2PgkZ8aPCTX8tD+8bAVeJR7LkHK4XU1Ojbnn8blamLTWguurYkvBg6SE/rCItsnasyemiiRTdR6hn82HeZWBdqPmBFVNeiXdCO49yzbADp1sLZybEJ/I7hipfw== MIME-Version: 1.0 X-Received: by 10.221.44.65 with SMTP id uf1mr17526782vcb.46.1423034706568; Tue, 03 Feb 2015 23:25:06 -0800 (PST) Received: by 10.52.74.73 with HTTP; Tue, 3 Feb 2015 23:25:06 -0800 (PST) In-Reply-To: <00c101d04049$ca411ec0$5ec35c40$@tekwire.net> References: <00c101d04049$ca411ec0$5ec35c40$@tekwire.net> Date: Wed, 4 Feb 2015 11:25:06 +0400 Message-ID: To: francois@tekwire.net Cc: Yasuo Ohgaki , Joe Watkins , PHP Internals , Andrea Faulds , Nikita Popov Content-Type: multipart/alternative; boundary=001a11c3ea3c303f96050e3e162c Subject: Re: [PHP-DEV] What do we need strict scalar type hints for? From: dmitry@zend.com (Dmitry Stogov) --001a11c3ea3c303f96050e3e162c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable The idea of that RFC was an ability to have zero-cost assert(). DbC is a much more bigger feature, it is interesting, but requires significant work. Thanks. Dmitry. On Wed, Feb 4, 2015 at 10:11 AM, Fran=C3=A7ois Laupretre wrote: > > De : Dmitry Stogov [mailto:dmitry@zend.com] > > Hi Yasuo, > > > > You probably talk about https://wiki.php.net/rfc/expectations > > I wasn't the author of idea, I just helped with thoughts and > implantation. > > I think it may be useful for PHP7. > > In accordance with Yasuo's suggestions, couldn't we consider assertions a= s > part of a future implementation of the wider 'design by contract' concept= ? > > DbC could handle : > > - function inputs : 'smart' built-in arguments types (keeping loose > typing), constraints on possible values > - function output : accepted return types/values > - assertions anywhere in the code > > Function input/output validation would be done using built-in 'smart' > types ('string', 'numeric', 'integer', etc), and, optionally, 'validator' > functions. These could validate any aspect about argument/return type and > value. The key point with DbC (as well as assertions) is that, as there's > no constraint on performance, validation can be very precise and can run = in > userland code. > > For function input/output validation, I would extend the phpdoc syntax > (keeping compatibility with existing comments). > > Another suggestion for assertions : if we hide it in comments (something > unusual like '//@@assert(...)'), we probably don't need to define an opco= de > and it can be implemented as a standard function. > > The question of whether DbC should replace or just supplement arg/return > typing remains open :). > > What I suggest, if you agree, is that, even if we don't implement the > whole DbC concept now, we could already consider assertions as being part > of it, and rename zend.assertions to zend.dbc, assert.exceptions to > dbc.exceptions, and AssertException to DbcException. > > Regards > > Fran=C3=A7ois > > > --001a11c3ea3c303f96050e3e162c--