Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52062 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20961 invoked from network); 28 Apr 2011 17:22:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2011 17:22:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=martinscotta@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=martinscotta@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: martinscotta@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:39335] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/A2-03888-562A9BD4 for ; Thu, 28 Apr 2011 13:22:46 -0400 Received: by vwl1 with SMTP id 1so2458977vwl.29 for ; Thu, 28 Apr 2011 10:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=zkb3u5DNqRajXlhhffidu/fa8lup0gwG9C2nsCH01VA=; b=kwy/M+Y2UhXednr3VVG2Zll+it/KDZGBRC6joANlnwEaRVQjXkvwXn8x287J7y6ert t/T2L9WsbDIbjfNfZGmPNizArVNgIunq+rCyGhKj+8Y1KBH2ynkqfnP0FrRC9nBmGTip WC7OICQC/oObK04lKXHUwpOly2eg8maPr1VV4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=c01DsfLo8arSMEuDWLuHnmVB2p3j8DEYkOXqFBwcEUReWEOsxb4zIFEFqNaEf1bWM1 QZOfF/ljbt7sYk7JuHGATKBq0oVTsFBbgDS4ZXFVqCfMbNR5PWj5YCAsCuL18BPH3iXi 6Ck0rEgJyvIuAzGiyVaS04wNpyVTUWmiW4Eds= MIME-Version: 1.0 Received: by 10.220.88.14 with SMTP id y14mr1130349vcl.43.1304011362619; Thu, 28 Apr 2011 10:22:42 -0700 (PDT) Received: by 10.220.189.197 with HTTP; Thu, 28 Apr 2011 10:22:42 -0700 (PDT) In-Reply-To: <4DB98E8A.409@yahoo.com.au> References: <4DB923E6.3020307@sugarcrm.com> <4DB98E8A.409@yahoo.com.au> Date: Thu, 28 Apr 2011 14:22:42 -0300 Message-ID: To: Ben Schmidt Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=0016e6471c780d50ef04a1fdceac Subject: Re: [PHP-DEV] [RFC] Return type-hint From: martinscotta@gmail.com (Martin Scotta) --0016e6471c780d50ef04a1fdceac Content-Type: text/plain; charset=ISO-8859-1 Martin Scotta On Thu, Apr 28, 2011 at 12:58 PM, Ben Schmidt wrote: > 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. > Yes, PHP is interpreted, but remember that PHP has its own "compile-time". An option could be to use the "hints" only for compile purposes, but then at runtime the core can behave as it's today. > > 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? >> > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0016e6471c780d50ef04a1fdceac--