Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49302 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2761 invoked from network); 11 Aug 2010 00:51:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2010 00:51:05 -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.113 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.113 smtp113.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.113] ([67.192.241.113:38563] helo=smtp113.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/C2-20356-8F3F16C4 for ; Tue, 10 Aug 2010 20:51:05 -0400 Received: from relay11.relay.dfw.mlsrvr.com (localhost [127.0.0.1]) by relay11.relay.dfw.mlsrvr.com (SMTP Server) with ESMTP id E741C180451; Tue, 10 Aug 2010 20:50:56 -0400 (EDT) Received: by relay11.relay.dfw.mlsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 6035F18044C; Tue, 10 Aug 2010 20:50:56 -0400 (EDT) Message-ID: <4C61F3EF.5030409@sugarcrm.com> Date: Tue, 10 Aug 2010 17:50:55 -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: Arvids Godjuks , Internals References: <1281478269.6608.292.camel@guybrush> <4C61E5CA.5070604@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 (was: Typehints) From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > First of all, I am talking about the typehinting syntax and mechanism > here. As Derick pointed out, current typehints are strict. Talking about "strict" vs. "non-strict" for class types is meaningless. You can consider them non-strict if you want - they convert if the conversion is available, just like the rest of PHP, with only note that conversion is *never* available. But it's just a semantic game because we are talking about different things here. Using the same syntax just confused you to think they are the same, but in PHP they are not. There are some languages where there's no primitive types or primitive types aren't different from classes - but PHP, for better or worse, as of now is not one of them. > Secondly, I don't support amalgaming userland with internal functions. > If I was to treat those internal functions as if they were written in > userland, I'd say that they don't use scalar typehints, specifically > for the reason you mentionned. Internal functions just typecast > whatever you throw at them, no question asked. Again, it's just semantic games - you can call it "typehints" or not, your choice, but the fact is they did not fixate on the bitwise representation of the types - and we shouldn't start fixating on that now. They accept "1" when numeric value is needed, why can't you? > Again, I'm not talking about internal functions but typehinting. Now, > when a userland developer uses typehints it means they expect a > variable of a certain type to be passed. If they want typecasting, > Derick proposes a convenient way to do that. That's exactly what is wrong with it - developer should NOT expect "variable of certain type to be passed" (if we are talking about primitive types), because PHP is not a strictly typed language, it's a dynamic language. There could be strictly typed language with PHP syntax, no problem, but that would a) require much more than just function parameters and b) not be PHP. > The current typehinting system does not typecast. Changing that > behaviour makes it ambiguous. It introduces a new behaviour grafted > onto the old mechanism and without a new syntax. It does not change any behavior - right now there's two sets of objects in PHP - primitive types and classes. Values of primitive types can be converted into another type, implicitly or explicitly, objects of classes can not. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227