Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74112 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71852 invoked from network); 9 May 2014 21:56:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2014 21:56:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=prvs=020629dd0a=jwatzman@fb.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jwatzman@fb.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain fb.com designates 67.231.153.30 as permitted sender) X-PHP-List-Original-Sender: prvs=020629dd0a=jwatzman@fb.com X-Host-Fingerprint: 67.231.153.30 mx0b-00082601.pphosted.com Linux 2.5 (sometimes 2.4) (4) Received: from [67.231.153.30] ([67.231.153.30:32840] helo=mx0b-00082601.pphosted.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/D3-46741-BFE4D635 for ; Fri, 09 May 2014 17:56:13 -0400 Received: from pps.filterd (m0004060 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id s49Lp2S1008272; Fri, 9 May 2014 14:56:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : mime-version; s=facebook; bh=HzJ/uVGDfpvLcZq+L/SXJHeDPD0vK8vS2cBZqgAqA28=; b=FFrOSv8urX/cg/c7k5F1fyjdg+P3jMd4h3ZC/q8VbRNob7Jq/o+64lhCUTA44WBPyyFM SKObCFHYiqVbUVqqpAWreE5iT+FuqcqFTbY3E+T3JHgIk41BrkkwKSL0vjQVIsIk9de7 4j3+6uifIMKqYzz5wd0logCivrFRvhCb1Rk= Received: from mail.thefacebook.com (mailwest.thefacebook.com [173.252.71.148]) by mx0b-00082601.pphosted.com with ESMTP id 1krm6n4vxx-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Fri, 09 May 2014 14:56:07 -0700 Received: from PRN-MBX02-2.TheFacebook.com ([169.254.5.125]) by PRN-CHUB16.TheFacebook.com ([fe80::7948:a494:45d7:3dd9%12]) with mapi id 14.03.0174.001; Fri, 9 May 2014 14:56:05 -0700 To: Levi Morrison CC: internals Thread-Topic: [PHP-DEV] [RFC] Return Type Declarations pre-vote follow-up Thread-Index: AQHPa5iwbRN8uH8IdkWOuZ8Vefj2F5s5InuAgAAU3YCAAAMQgIAAAZ+AgAAFEgA= Date: Fri, 9 May 2014 21:56:04 +0000 Message-ID: References: <90B71511-4FB4-4916-9AC0-E3DD0D328C37@fb.com> <536D46C5.7040302@sugarcrm.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.16.4] Content-Type: multipart/alternative; boundary="_000_C4435E53F8DB48238C81E3DDE9169D91fbcom_" MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.96,1.0.14,0.0.0000 definitions=2014-05-09_08:2014-05-09,2014-05-09,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=0 kscore.compositescore=0 circleOfTrustscore=491.239897532764 compositescore=0.530276764690821 urlsuspect_oldscore=0.530276764690821 suspectscore=0 recipient_domain_to_sender_totalscore=15 phishscore=0 bulkscore=0 kscore.is_spamscore=0 recipient_to_sender_totalscore=0 recipient_domain_to_sender_domain_totalscore=1996008 rbsscore=0.530276764690821 spamscore=0 recipient_to_sender_domain_totalscore=0 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1405090285 X-FB-Internal: deliver Subject: Re: [PHP-DEV] [RFC] Return Type Declarations pre-vote follow-up From: jwatzman@fb.com (Josh Watzman) --_000_C4435E53F8DB48238C81E3DDE9169D91fbcom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable On May 9, 2014, at 2:37 PM, Levi Morrison > wrote: On Fri, May 9, 2014 at 3:32 PM, Josh Watzman > wrote: > I'm not sure it is a good idea. This means having this code: > class FooGetter { > function getFoo(): Foo { return new Foo(); } > } > > I can extend it as: > class TwoFaceFooGetter extends FooGetter { > function getFoo() { return rand()%2?new Bar():new Foo(); } > } > > and every function getting FooGetter and expecting getFoo() to return > Foo is now broken since instead it could just get Bar(). Since the type > return specification is meant, as far as I understand, exactly to avoid > cases like that, I don't see it as a good idea. Our view is that this code was *already* wrong. The type annotations don't = make it more or less wrong. What they do let you do is enforce, once the an= notation is in place, that it's correct moving forward for the places that = are annotated. (And if you want to go fix up and annotate TwoFaceFooGetter,= go do that! Or if you don't right now, don't!) Doing it this way also mean= s that you don't have to convert your entire hierarchy all at once -- gradu= al conversion of existing code was an important feature when we were adding= the Hack type system onto PHP. The behavior you are proposing is good for migration and adoption, but what= then? What about the years afterwards where you now have this ability to b= reak the return type? It's much harder to remove this behavior than it is t= o add it in later. Hack has "strict mode" (http://docs.hhvm.com/manual/en/hack.modes.strict.ph= p) which simply doesn't let you omit an annotation anywhere, which you can = use to "lock in" a fully annotated file. We were also just discussing that = it might make sense to enforce strict mode for an entire hierarchy, though = we don't have anything like this right now. New Hack code can be all strict= and thus all type-safe. I'm not sure if you'd want to actually add some notion of per-file "modes" = like this, but it's been important to our type system adoption. Having some= way to gradually type things was critical for us. The slightly higher leve= l of safety you get from the stricter enforcement doesn't matter if the vas= t majority of folks (existing code) can't use it ;) But as you say, it's a lot easier to loosen in the future; since this propo= sal is stricter than HHVM, I've said my piece and will get out of your way = ;) I wish you'd change your mind here, but I still think the RFC as it stan= ds is both a good step for PHP in and of itself, as well as a good step clo= ser to Hack. Josh Watzman --_000_C4435E53F8DB48238C81E3DDE9169D91fbcom_--