Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52058 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8033 invoked from network); 28 Apr 2011 15:58:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2011 15:58:12 -0000 Authentication-Results: pb1.pair.com header.from=mail_ben_schmidt@yahoo.com.au; sender-id=unknown; domainkeys=good Authentication-Results: pb1.pair.com smtp.mail=mail_ben_schmidt@yahoo.com.au; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain yahoo.com.au from 98.139.91.96 cause and error) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: mail_ben_schmidt@yahoo.com.au X-Host-Fingerprint: 98.139.91.96 nm26.bullet.mail.sp2.yahoo.com Received: from [98.139.91.96] ([98.139.91.96:37847] helo=nm26.bullet.mail.sp2.yahoo.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/70-03888-19E89BD4 for ; Thu, 28 Apr 2011 11:58:11 -0400 Received: from [98.139.91.69] by nm26.bullet.mail.sp2.yahoo.com with NNFMP; 28 Apr 2011 15:58:06 -0000 Received: from [98.139.91.21] by tm9.bullet.mail.sp2.yahoo.com with NNFMP; 28 Apr 2011 15:58:06 -0000 Received: from [127.0.0.1] by omp1021.mail.sp2.yahoo.com with NNFMP; 28 Apr 2011 15:58:06 -0000 X-Yahoo-Newman-Id: 6415.78811.bm@omp1021.mail.sp2.yahoo.com Received: (qmail 52905 invoked from network); 28 Apr 2011 15:58:05 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=nTMnVOXmPK+aznrrsL7v4j6SgJQiWhFYOvKYpMWAhu1yK1JMwbgmBvrJmyWrjSPijBjjW9X6jb+wgNX1XjaXus0DFDHL/A1pnO/ZXQEiiO2Dce1TvA0APkw65v3rzRQobTBKgU6BLyu9sfhZAOC2UxZaIady+5/T/F8aU8CJWX4= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.au; s=s1024; t=1304006285; bh=//r3cADML7HJ1mangBnhFSxS9AEySBjFJ5d7uOyhruQ=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=4bD8Sd7YtYxoE2jKmzLPgQR5HrGZqM6YxXWqOXVxbNmHs57jAE5NFBLRL4Wl3zbVNqqPITW1+yhth0x34IiTGnoWSfVc9FBvwvqsim6d9EFs1RdqDKIc4AdG9iXkVmadndoZgHWIVlZ1QFy6mO9IcGVlQT2Dg/vnHvU+jcuBp1M= Received: from thought.local (mail_ben_schmidt@124.168.81.69 with plain) by smtp139.mail.mud.yahoo.com with SMTP; 28 Apr 2011 08:58:04 -0700 PDT X-Yahoo-SMTP: enFMnPSswBAexaHyzgobwuUTrYOhZdJ0KRA2SjA- X-YMail-OSG: 2EY3PHgVM1m3iisKeyT2Y4p.LTxkTjv194Afyrsx__H_m7z ZYtZMu.dR940GRDQNGJ03_pYk9xlriSxP_PWO6Jhveyf7frJTxkqQuDR1fnA 60PTXm1jHWIzE2f0A1004ZIP6fI._f5J7.RBlIp6EBnuJkxOGK07ERfBeiPZ ZimTEloXf2acJvmyMP7Q4KBfQLhpgGL8McOmW2WOZE0G1wFCcxqsfpRM53vz WfE8VWjAyI6oSKaax.eA8jUOpQV6WUiy8L4BM3L1oS84yJd7ct8UxUVSmX.A qg2FufluiJbfq0lZDsoyZJSNSVqJ7unHxPUTUUqpuqXcFItu5l695u_KLiVi cFIFd.mqvSRnpgQIUHkxm X-Yahoo-Newman-Property: ymail-3 Message-ID: <4DB98E8A.409@yahoo.com.au> Date: Fri, 29 Apr 2011 01:58:02 +1000 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5 MIME-Version: 1.0 To: internals@lists.php.net References: <4DB923E6.3020307@sugarcrm.com> In-Reply-To: <4DB923E6.3020307@sugarcrm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Return type-hint From: mail_ben_schmidt@yahoo.com.au (Ben Schmidt) FWIW, I don't see much point in this either, as far as error reporting is concerned. I think type checking for parameters can provide cheap and useful validation, as parameters passed in are outside the function's control. But return values? They are within the function's control, and in most functions are not hard to ensure are correct without needing runtime checking. If PHP were compiled, not interpreted, i.e. less dynamic, there could be some benefits, as compile-time optimisations could perhaps be built in, and validations skipped if they were provably unnecessary. But that's not going to happen any time soon, as far as I'm aware. So the only real benefit is that they could make code slightly self-documenting. But since they would still be optional, they don't help much: the coder might as well take up the option to write some more useful documentation. Also, PHP has so many conventions such as returning false on error that don't fit cleanly into the model, that it's awkward. I'd love to see those problems solved neatly for function arguments before extending anything to function return types. I don't think it would do any harm though, so don't see any argument against it. I just don't think there's a good argument for it. Ben. On 28/04/11 6:23 PM, Stas Malyshev wrote: > Hi! > >>> http://wiki.php.net/rfc/returntypehint >> for the upcoming 5.4 release, I think it would be extremely useful, even >> without the scalar stuff. > > > Personally, I see even less point in having strict return typing (please stop > using "hint" terminology, it confuses the whole matter, it's not "hint" if it > describes mandatory restriction on the data) than strict argument typing. The RFC > doesn't explain it either beyond "here how you can have some nice errors". > But why would I want to see these errors? How they would make anything easier or > better?