Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82340 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25590 invoked from network); 10 Feb 2015 07:21:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Feb 2015 07:21:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.178 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.178 mail-vc0-f178.google.com Received: from [209.85.220.178] ([209.85.220.178:36826] helo=mail-vc0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/49-47508-171B9D45 for ; Tue, 10 Feb 2015 02:21:22 -0500 Received: by mail-vc0-f178.google.com with SMTP id hq11so7940577vcb.9 for ; Mon, 09 Feb 2015 23:21:19 -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=Qcm8dtw+qOmACc2XDKonGxJr/VoaA3WphP0B/tMaiCQ=; b=Cn8u2SFyQEH8M3dUB08zpQNpq6yCb9WjUBt8sPMRsGAJXwRG3pGWw/LosEf2kIZvpf O2FHTNNjwf/sPkMr00yrFM9MEGkSbEZKCajMIqpjVvTbetVdNAN3ei2HcumfhSerGQ5h tHZ2MUDv8Iv1uExVEu8e5nF8mHCzfUzXa+V8AhCOu6GVT8mhSwo+k8q9cJopg9/0BDiC ipYOZUErQZQTcoXJH/cifzmIuEnIhDU2pxg5wC7WdceULAjhyOgIzKQkUCL9S1d2saqe jUJ37WkPfdAgKwsPdMAzd7LHrygbUiBwuFDTI7ezG5nIHe49dNza/Mp1dJXZghk9DVij d1kQ== X-Gm-Message-State: ALoCoQnb3q0aJriWnvAbXTDHQmqQnfAh+lgvowXeX535PoMT8w36aBw0WuStWc0k4Is8ZmpeRbxkA+dD7QvKx22G++trgHhpMoBTKkOD6lSj3ARRv9e3lYixu5qSHL4cR46GU2UyVWonYaRb199rDnlY882ruaA3pg== MIME-Version: 1.0 X-Received: by 10.220.185.193 with SMTP id cp1mr13562640vcb.80.1423552879103; Mon, 09 Feb 2015 23:21:19 -0800 (PST) Received: by 10.52.74.73 with HTTP; Mon, 9 Feb 2015 23:21:19 -0800 (PST) In-Reply-To: References: <54D7ED22.3080001@gmail.com> Date: Tue, 10 Feb 2015 11:21:19 +0400 Message-ID: To: Patrick Schaaf Cc: Yasuo Ohgaki , internals Content-Type: multipart/alternative; boundary=089e01538610ada9c0050eb6bb9f Subject: Re: [PHP-DEV] Design by Contract From: dmitry@zend.com (Dmitry Stogov) --089e01538610ada9c0050eb6bb9f Content-Type: text/plain; charset=UTF-8 On Tue, Feb 10, 2015 at 10:06 AM, Patrick Schaaf wrote: > Am 10.02.2015 07:25 schrieb "Yasuo Ohgaki" : > > > > https://wiki.php.net/rfc/dbc2 > > First of all, thanks for your effort so far. > > Some questions, after reading the RFC, with no particular order: > > 1) Regarding invariants: those will be called for method calls on objects. > What about static class methods? Could we have static class invariants > (static require(.....))? Would these be called for both static and > nonstatic method calls (nonstatic method calls can change static class > state, too) > yeah, "static require()" may be a good addition. However, I don't like to invite a bicycle, we are going to borrow most related semantic from D. > 2) the pre- and postconditions could be useful for ordinary, non-OO > functions, too, to check parameters, return, and global state invariants > any function will able to use contracts. 3) I think that method preconditions are not sufficient. Pretty often, > public methods first sanitize and validate their input parameters, and > rightly so. In these cases, it would be useful to have the checking, in the > same general framework, at an arbitrary point in the function body. In > other words, assert (with an expression as the first argument, instead of a > string....). > assert() will work as well. Actually, all these addition require/return syntax is going to be just a syntax sugar that will finally call assert()s in proper order. > 4) regarding the error message second argument to the condition > definitions, it would be useful to have these not only as plain > (extrapolated) strings, but as full expressions-that-evaluate-to-string. > That would permit hooking to arbitrary private logging and log formatting > methods. > I don't think we will implement this. It may be proposed later as a DbC extension. > 5) and a bit off-topic, it would be useful to be able to declare (sic) > whole methods to be nonproduction only: Methods that will only be used in > pre/post/invariant condition expresions (or error formatters a la my point > 4) > this is also not directly related as well. Sorry, but we should define realistic target to be able to provide a working solution. We can't think about all possible and indirectly related features at once. Thanks. Dmitry. > best regards > Patrick > --089e01538610ada9c0050eb6bb9f--