Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49358 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64485 invoked from network); 11 Aug 2010 17:20:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2010 17:20:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.193 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.193 smtp193.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.193] ([67.192.241.193:51996] helo=smtp193.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/BB-01618-CEBD26C4 for ; Wed, 11 Aug 2010 13:20:46 -0400 Received: from relay19.relay.dfw.mlsrvr.com (localhost [127.0.0.1]) by relay19.relay.dfw.mlsrvr.com (SMTP Server) with ESMTP id 4E0722748579; Wed, 11 Aug 2010 13:20:42 -0400 (EDT) Received: by relay19.relay.dfw.mlsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id F31272748312; Wed, 11 Aug 2010 13:20:41 -0400 (EDT) Message-ID: <4C62DBE9.7090008@sugarcrm.com> Date: Wed, 11 Aug 2010 10:20:41 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6 MIME-Version: 1.0 To: Josh Davis CC: Internals References: <1281478269.6608.292.camel@guybrush> <4C61E5CA.5070604@sugarcrm.com> <4C61F3EF.5030409@sugarcrm.com> <4C6241D1.6030909@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Strict typing From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > Yeah, hmm, no, and it is disingenuous of you to equate type hints to > PHP becoming statically typed. I'm sure that some people would love to See? That's exactly why I am so opposed to calling it "type hints". Because if you called it proper name - strict typing, you'd say "it is disingenuous of you to equate strict typing to PHP becoming statically typed" and it'd make you think that maybe it doesn't sound good. > have optional static typing in parts of their code, but I like being > able to use my vars freely when I need to. Being able to enforce what That only leads to very bad coding practices. If you have strictly typed parameter "int $foo", any data path that leads to $foo should be verified to always produce "int" - otherwise your code blows up at runtime (no compile-time checks, remember?). That can be achieved in one of two ways: 1. Having convert/check before each call to the function 2. Having variables and parameters to upstream functions typed 1 is insanely-ugly code, 2 is static typing. You choose. > PHP being dynamically typed shouldn't be an argument to prevent people > from enforcing method signatures. You're saying that PHP users should > have no control over what variable types are passed to their > functions. No, I'm not saying that. I'm saying, see above, that there are consequences to strictly typed parameters. You can, of course, choose third way and have half-assed implementation, but that would prove to work badly very quickly. As soon as you discover it, you'd ask for typed variables and typed returns and typed properties, etc. etc. Enter static typing. The fact that you won't use it for every variable doesn't matter. > More seriously, one of PHP's most popular quality is that it is > flexible. When I started using PHP, I would never initialize variables Flexible doesn't mean "changes at my every whim without regard for consequences". This change is bad. It should be rolled back. > back then no one told me "oh you want warnings on initialized > variables? You should use C++ then! Haha!" PHP was flexible enough to Unitialized vars notice is one of the great mistakes in PHP. The amount of ugly boilerplate code that it brings along is mind-boggling. You can't just say if($_REQUEST['blah'] == 'blah') do_stuff(); - you have to put isset() there or you get a very costly, annoying and completely useless error message. It was a mistake to create it. But that's another discussion, not for now. > to their functions what they want. And you're against that on... > ideological grounds? I'm against it on sanity and logic grounds. I explained the reasons (for the Nth time) above. If you still can't comprehend that there's logic behind what I am saying and call it "ideology" - well, I guess there's a limit of what one can explain. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227