Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57035 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78439 invoked from network); 22 Dec 2011 22:07:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 22:07:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=will.fitch@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=will.fitch@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: will.fitch@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:54704] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/24-12618-E1AA3FE4 for ; Thu, 22 Dec 2011 17:07:26 -0500 Received: by qcsd16 with SMTP id d16so5635561qcs.29 for ; Thu, 22 Dec 2011 14:07:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=po7zgkGWhGeBcLbkiKvR+bF5fWvcG+woH+bJB2/0EU8=; b=iKNPvamZJb35HyKBhHCyo+82wzbnuBRMQbnvB2ECrKAQMpRPnU5/z+wwf1fDwHKVPC CswrqNCAi48lOhrwItNfe2FCJIju6u8m/X1S0hVzJGZvUp7OByZlYzYIh8sR84xm31WB uf/8ZfnqxSXUfb+SQRPPfT7+2Eqq9k5bhL7fw= Received: by 10.229.134.196 with SMTP id k4mr4879356qct.29.1324591642884; Thu, 22 Dec 2011 14:07:22 -0800 (PST) Received: from [192.168.1.68] ([68.64.144.221]) by mx.google.com with ESMTPS id z1sm19819328qao.1.2011.12.22.14.07.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Dec 2011 14:07:21 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii In-Reply-To: Date: Thu, 22 Dec 2011 17:07:19 -0500 Cc: Paul Dragoonis , Rasmus Lerdorf , Keloran , Dmitri Snytkine , Alain Williams , "internals@lists.php.net" Content-Transfer-Encoding: quoted-printable Message-ID: References: <2095305E-D4E3-4D7E-8218-32EE99688E0C@GMAIL.COM> <2C90FB94-38C4-4270-8C6A-B89304BA8ED8@gmail.com> <159A7CA2-8561-40DA-9434-CAAE12304DDB@gmail.com> <005701ccc0b3$58c8dee0$0a5a9ca0$@alliantinternet.com> <20111222145159.GY25857@alliantinternet.com> <006101ccc0ba$46b81160$d4283420$@alliantinternet.com> <4EF379D8.9000206@lerdorf.com> To: John Crenshaw X-Mailer: Apple Mail (2.1251.1) Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: will.fitch@gmail.com (Will Fitch) So, are we in agreement that, within the scope of this RFC, type hinting = is going to be limited to and match parameter type hinting? On Dec 22, 2011, at 3:35 PM, John Crenshaw wrote: > From: Paul Dragoonis [mailto:dragoonis@gmail.com]=20 >=20 >> On Thu, Dec 22, 2011 at 6:41 PM, Rasmus Lerdorf = wrote: >>=20 >>> On 12/22/2011 07:08 AM, Keloran wrote: >>>> i would love to see this expanded aswell (the way type hinting on >>> function >>>> variables was supposed to be), so that it could be >>>>=20 >>>> string, int >>>>=20 >>>> e.g. >>>> function int test(bool $tester) { >>>> if ($tester) { return 5; } >>>> return 99; >>>> } >>>=20 >>> Return type hinting needs to be aligned with parameter type hinting,=20= >>> and as has been pointed out many times on this list, type hinting = for=20 >>> interchangable scalar types is a really bad idea. It will push all=20= >>> type checking up to the caller of the underlying functions/methods.=20= >>> PHP is primarily a Web scripting language and the Web isn't typed.=20= >>> Having stuff like this break: >>>=20 >>> if(age_check($_POST['age'])) { do_stuff(); } >>>=20 >>> because the author of the age_check() function added an int type = hint=20 >>> just doesn't make any sense. It would cause everyone to have to = start=20 >>> casting things everywhere, just in case. eg. >>>=20 >>> if(age_check((int)$_POST['age'])) { do_stuff(); } >>>=20 >>> This is not a step forward. If the author of age_check() really=20 >>> doesn't want to accept type-juggled arguments, then it is easy = enough=20 >>> to do a strict type check in the function itself. This puts the = effort=20 >>> in the correct place and doesn't encourage this type of coding. >>>=20 >>=20 >> I agree with Rasmus. >>=20 >> My opinion: >> This isn't java, if you want a strongly typed language, there's = plenty out there, but we're not looking to make PHP more like Java and = the rest, if it was like Java then it wouldn't have been successful for = the web as it is/was. PHP is popular because of the way it was from the = start, if php _needed_ scalar typehints then it wouldn't have been as = popular. >=20 >> There is need for the existing Typehinting for class types so you = don't need to have is_a() function calls. This makes sense. >=20 >> Scalars are VERY powerful in PHP, because of its loose typed nature. = Having a 'numeric' typehint makes sense, because it can be an int, = float, or string. Adding typehints like 'int' and 'float' will only piss = people off, and make PHP more difficult and less fluent to code in. >=20 >> Lets not go there please.. >=20 >> Thanks, >> Paul Dragoonis. >>=20 >>=20 >>=20 >>>=20 >>> -Rasmus >>>=20 >>> -- >>> PHP Internals - PHP Runtime Development Mailing List To unsubscribe,=20= >>> visit: http://www.php.net/unsub.php >>>=20 >>>=20 >=20 > Slightly off topic, but I keep seeing this problem: >=20 > "PHP is not language X" is a terrible argument. This is a smokescreen = designed to insult the other person, belittle their concerns, and avoid = discussing the real issue. This doesn't advance the discussion at all.=20= >=20 > Concluding that PHP is popular because you can't {insert requested = feature here} is also ridiculous but it happens again and again whenever = language features are discussed. PHP is popular independent of not = {insert missing feature here}. It is popular because it was on the scene = early, has good server support, and does an excellent job of making it = trivial to handle most simple web requests. >=20 > Nobody wants to be told to shut up and go use language X. >=20 > Let's discuss things on their own merits. >=20 > /rant >=20 > John Crenshaw > Priacta, Inc. >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20