Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52074 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43914 invoked from network); 28 Apr 2011 19:34:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2011 19:34:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:61913] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/62-29189-731C9BD4 for ; Thu, 28 Apr 2011 15:34:16 -0400 Received: by vxb40 with SMTP id 40so2570596vxb.29 for ; Thu, 28 Apr 2011 12:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=sOsleFId/otK6nUoGZ4sxECy5NbdFa98egwRYU8lHAs=; b=H7HeozbLcZgzi9KNIKEDAJGdzHHTP/XT8YqPdHcg7lmSJlgoQpSBXaFsWOoDA+j9V+ 88NNECRiR53nCTTZYW9rQI4Q6fQ723gt+s03uFP2uoHcIUSnB9e1NrtkIx/JoM418AFG z5B99Ksr5QMsNee7HnxT8vy1OE0b61CrJLxk4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=t/q7/uX/W8l3tuewQ59G4/uxcVCt9jDXZFfi/Jm4duZYFQ9vELsIy7lbF8nYhkANmJ I080y+NGff2uvjdS8VNUqj2JROoUYiuC33HpabFQavGJUnx70yrFtVwwjUWI2Qe5MRTc JMgnGOumCy2/4WFAJEEaKHXcJY6zeIzMichyI= MIME-Version: 1.0 Received: by 10.52.74.34 with SMTP id q2mr5509036vdv.114.1304019253153; Thu, 28 Apr 2011 12:34:13 -0700 (PDT) Sender: tyra3l@gmail.com Received: by 10.52.188.161 with HTTP; Thu, 28 Apr 2011 12:34:13 -0700 (PDT) In-Reply-To: <4DB9B6B3.1090401@sugarcrm.com> References: <4DB923E6.3020307@sugarcrm.com> <4DB9A7BE.6010307@sugarcrm.com> <4DB9B6B3.1090401@sugarcrm.com> Date: Thu, 28 Apr 2011 21:34:13 +0200 X-Google-Sender-Auth: Hho4Lf-t97o6glnZqxt_rQBXbzI Message-ID: To: Stas Malyshev Cc: Felipe Pena , internals Content-Type: multipart/alternative; boundary=20cf3071c7fc5d521a04a1ffa40c Subject: Re: [PHP-DEV] [RFC] Return type-hint From: info@tyrael.hu (Ferenc Kovacs) --20cf3071c7fc5d521a04a1ffa40c Content-Type: text/plain; charset=UTF-8 On Thu, Apr 28, 2011 at 8:49 PM, Stas Malyshev wrote: > Hi! > > > it's the same as for the current argument type hinting. >> you can access that information via Reflection >> http://hu2.php.net/manual/en/reflectionparameter.getclass.php >> > > Really? That's how you write your code - do a reflection check before every > call? Nobody does that. > > I didn't said that, probably I shouldn't have mention that, we are both aware of the capabilities of Reflection imo. but it's still true, that it would behave the same way as it does now for the argument type hinting. you didn't reply on that, so I think we agree on that. > > why did we added ppp if people can define in the documentation(or in the >> method name :/) that which method is public and which isn't >> > > Well, this is a good argument, PPP case seems close. Still, PPP is not > really as dynamic as variable types are - PPP picture is much simpler and it > also serves the call target, not the caller - i.e., the caller does not rely > on pretty much anything in PPP, while the target relies on its protected > functions not being called by strangers. > So my main objection is that return typing doesn't actually serve the > caller. > true, and Johannes brought this up also, but I didn't wanted to compare the ppp to return type hinting. I'm just saying that you argument "Why I need being "saved" from documenting my code properly?" isn't apply here. Because by this logic we could remove a lot of things, things which allows the developers to express their code more explicitly. "Anyway, the function code defines the behavior, declaration of return type just ensures function would fail in runtime if your code tries to return unexpected data - but how is it helpful?" as I mentioned I can imagine cases when we can spot errors before actually executing the code, but I don't know enough about the internals to tell that this could be viable or not. > Also, the fact that for PHP is extremely common to return null/false from > methods on error makes a big hole in this concept even if we accepted the > return typing as a counterpart to existing argument typing. E.g., seeing > something like: > function (Foo|Bar|false|null) ugly() > makes me fill dizzy. This doesn't look like something we'd want. > > yeah, but usually you return null/false in case of error when you write procedural code. but since we wouldn't support the return typehint for scalars, maybe we could assume that the only sane people who would use this feature would also do the error handling will through Exceptions (@throws :P). Tyrael --20cf3071c7fc5d521a04a1ffa40c--