Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58276 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55338 invoked from network); 28 Feb 2012 20:58:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2012 20:58:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=johncrenshaw@priacta.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=johncrenshaw@priacta.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain priacta.com designates 64.95.72.244 as permitted sender) X-PHP-List-Original-Sender: johncrenshaw@priacta.com X-Host-Fingerprint: 64.95.72.244 mxout.myoutlookonline.com Received: from [64.95.72.244] ([64.95.72.244:64541] helo=mxout.myoutlookonline.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/A3-36673-8FF3D4F4 for ; Tue, 28 Feb 2012 15:58:33 -0500 Received: from mxout.myoutlookonline.com (localhost [127.0.0.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id 9F442416DFE; Tue, 28 Feb 2012 15:58:29 -0500 (EST) X-Virus-Scanned: by SpamTitan at mail.lan Received: from HUB016.mail.lan (unknown [10.110.2.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id 556A1416BC6; Tue, 28 Feb 2012 15:58:27 -0500 (EST) Received: from MAILR001.mail.lan ([10.110.18.27]) by HUB016.mail.lan ([10.110.17.16]) with mapi; Tue, 28 Feb 2012 15:58:10 -0500 To: Adam Richardson CC: PHP Development Date: Tue, 28 Feb 2012 15:58:22 -0500 Thread-Topic: [PHP-DEV] Scalar type hinting Thread-Index: Acz2Vh00HLY/WnQMR9CUT5mqqbvtNwAAc8Fg Message-ID: References: <1330357150.2159.30.camel@guybrush> <4F4C1324.2040905@gmail.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: multipart/alternative; boundary="_000_A633CF2D7C7BED41B41F1E64F25507B8069DC46CD9MAILR001maill_" MIME-Version: 1.0 Subject: RE: [PHP-DEV] Scalar type hinting From: johncrenshaw@priacta.com (John Crenshaw) --_000_A633CF2D7C7BED41B41F1E64F25507B8069DC46CD9MAILR001maill_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Adam Richardson [mailto:simpleshot@gmail.com] On Tue, Feb 28, 2012 at 2:53 PM, John Crenshaw > wrote: OK everyone, it seems that some people have forgotten or missed the origina= l agreement that this thread started with. There is a communication disconn= ect ("strict typing" means horribly different things to different people ri= ght now). Please read through and understand the following terminology befo= re continuing to post on this thread. We've agreed to the following terms: - "Strict Typing" means the super strict old C style typing *with no implic= it conversions*. (If you really think this is what you want, you are probab= ly mistaken. Look through prior discussions on this topic. This fails for n= umerous reasons, including the fact that almost every input to PHP is a str= ing.) Where is the term "strict typing" coming from? I've not seen this used to d= escribe any type system (doesn't mean it's not been used, but I'd really li= ke to see the usage so I can understand the label.) Adam, When you say you want "Strict" or "Strong" typing, this (case 1) is w= hat the opponents of stronger typing think you are asking for, which is why= I've defined it this way. There have been a tiny handful of individuals th= at really are asking for this, but most people don't really want this level= of strictness. Also, this level of strictness is fundamentally at odds wit= h the nature of PHP, and it's just never going to happen. The level of typi= ng in this first case is littered with problems. I won't get into it all, b= ut you can read prior discussions in the archives to see it. Look for the p= assionate arguments made by typing opponents that talk about "massive chang= es", "destroying the language", and "Go use JSP". Scattered in there are so= me occasional explanations of the actual core issues, all of which refer to= this level of typing. (Incidentally, even C++ is not this strict, so this = really isn't what you want, I'm sure of it. If this is what you want, then = this isn't the thread for you, because this is *not* what will be advocated= or discussed here.) - "Weak Typing" means types in the same sense that the PHP documentation us= es types (for example, the docs indicate substr(string, integer), and subst= r(12345, "2") =3D=3D "345".) (If you think you want "strict typing", this i= s probably what you mean.) Doesn't weak typing mean that the language implicitly converts types for us= e according to a set of rules? The opposite of this being strong typing, wh= ich means the language does not perform implicit conversions. "Weak" here really means weaker than the "Strong" above, but stronger than = "none". Right now PHP has no typing whatsoever. "weak typing" WOULD be typi= ng, but it is flexible, optional, and aggressively uses implicit conversion= s. For comparison, by these definitions C++ is halfway between "weak typing= " and "strong typing" (by virtue of operator overloads, overloaded function= s, and cast operators.) This "Weak typing" will give you what you want, and it can work. Most impor= tantly, it is *not* the thing that goes bump in the night for most strong t= yping opponents, which means it is probably possible to gather sufficient s= upport for this. This discussion is focused on developing a rock solid prop= osal for "weak typing". - "No Scalar Typing" should be used to indicate the current system (where t= here is no provision for hinting at scalar types.) And, curious about the "No Scalar Typing"? This is PHP right now. The language has no provision whatsoever for scalar = types. Function parameters can be hinted as an array or as a specific class= /interface, but otherwise they are assumed to be absolutely anything. I kno= w that for people with a lot of experience in a strongly typed language thi= s sounds like what they would normally call "Weak Typing", but it's a 3rd l= evel. "Weak Typing" under these definitions is a lot stronger than what you= would call "weak", but it's much weaker than what strong typing opponents = would call "strong". It's going to take some time to get used to the semantics, but if you want = any typing enhancements you're going to have to speak the language of the p= eople you want to convince. The communication disconnect here has been sink= ing this proposal for a decade. John Crenshaw Priacta, Inc. --_000_A633CF2D7C7BED41B41F1E64F25507B8069DC46CD9MAILR001maill_--