Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81932 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5435 invoked from network); 5 Feb 2015 14:55:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 14:55:45 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.53 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.216.53 mail-qa0-f53.google.com Received: from [209.85.216.53] ([209.85.216.53:45803] helo=mail-qa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/6F-27691-F6483D45 for ; Thu, 05 Feb 2015 09:55:43 -0500 Received: by mail-qa0-f53.google.com with SMTP id n4so6114817qaq.12 for ; Thu, 05 Feb 2015 06:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=tfXc0Lsx3HD1mwQtW1UveQf9JkKMcOLbOMQmiww3074=; b=Hmi2JqQSScXwGyxZhc8dFqXbOOBj1u0dIK1lzOPYQFdHLMXrDFZay3glTkC6ISwXD3 JD1wVo49tAZrR0IEdpZMi+KQ/NAv3hm9AGS4/hCF00Z/RAiIMkd1P0kZQvVcwd2DXZjp N6DlfX5tXPiVPoi9Sggn7SIsOrsFoU0A3dSYtVV1CBtV2YZpis9Efdd1Vaey+vhIIKV9 6tGDA5dmMGeURAfTyUY8Z6zm8v6e7LeVrh3ytnPUYNmsD3W2ao9fqT7PoVbTYL7X9/IZ g2/oWRIO8qf9i8e/X89qxqWHDjzDGETENXSbnrM2lZ40pEKPSxbAI4cyJJeSFp6l615V wQ1A== X-Received: by 10.224.114.209 with SMTP id f17mr9169450qaq.68.1423148140365; Thu, 05 Feb 2015 06:55:40 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.28.72 with HTTP; Thu, 5 Feb 2015 06:55:00 -0800 (PST) In-Reply-To: References: Date: Thu, 5 Feb 2015 23:55:00 +0900 X-Google-Sender-Auth: JGNGicNCg_ns_JnM4UW0HeoIA6k Message-ID: To: Dmitry Stogov Cc: PHP Internals Content-Type: multipart/alternative; boundary=047d7bdc19ac5e8e8b050e587fc7 Subject: Re: Design by Contract From: yohgaki@ohgaki.net (Yasuo Ohgaki) --047d7bdc19ac5e8e8b050e587fc7 Content-Type: text/plain; charset=UTF-8 Hi Dmitry, Thank you for your time! On Thu, Feb 5, 2015 at 8:14 PM, Dmitry Stogov wrote: > Following our conversation, I tried to imagine how DbC should look like in > PHP from user perspective. Finally, I was influenced by the semantic > proposed in D, and syntax proposed for Java. So, these are my initial > thoughts: > > For php it may look like the following: > > function foo() > require() > ensure() > { > ... > } > > It would require only one new reserved word "ensure". > Less reserved word is better. > > The assert expressions may be checked or not depending on ini directive. > It should be also possible to prevent code generation for assertions (zero > cost asserts). It was already implemented for > https://wiki.php.net/rfc/expectations > > For inherited methods, only the self should be > checked, and all parent . This is borrowed from D > but not necessary to be repeated exactly. > > I think we shouldn't introduce "invariant" constraints for classes now. > May be later. > > Implementation is going to generate code for input constraint after all > RECV opcodes and before code for function body, and code for output > constraint before RETURN opcode (may be reusing implementation of > "finally"). > It seems fine to me overall. I have a few questions, but I think it's better to handle discussion as I promised. I'll ask later! Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --047d7bdc19ac5e8e8b050e587fc7--