Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57993 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61916 invoked from network); 23 Feb 2012 23:39:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2012 23:39:22 -0000 Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-ww0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:42750] helo=mail-ww0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A5/0C-18992-92EC64F4 for ; Thu, 23 Feb 2012 18:39:22 -0500 Received: by wgbdq12 with SMTP id dq12so1481862wgb.11 for ; Thu, 23 Feb 2012 15:39:18 -0800 (PST) Received-SPF: pass (google.com: domain of kris.craig@gmail.com designates 10.180.99.100 as permitted sender) client-ip=10.180.99.100; Authentication-Results: mr.google.com; spf=pass (google.com: domain of kris.craig@gmail.com designates 10.180.99.100 as permitted sender) smtp.mail=kris.craig@gmail.com; dkim=pass header.i=kris.craig@gmail.com Received: from mr.google.com ([10.180.99.100]) by 10.180.99.100 with SMTP id ep4mr961667wib.7.1330040358991 (num_hops = 1); Thu, 23 Feb 2012 15:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=RXd1mQsCLF4Vk96T3iZgfP/ZxCyv72fuQxJ7tZzIEdY=; b=JQp2hsS4NMTRz+OnLNVesGPgfhLFWZYxfkWCfNKzPKrUO0KJ4IeaBHU+DVBOLRo3ep mHzy2Hw5obmmLtaIqeBNL3tqwLU9tnTYDmoeP94hRvRZTcgKsoyXyT9OdVt9qUqB1tvr pL0j8O47KTcrhxZOVBG0ccaaX9VZ3OH8Zlu+Y= MIME-Version: 1.0 Received: by 10.180.99.100 with SMTP id ep4mr777597wib.7.1330040358934; Thu, 23 Feb 2012 15:39:18 -0800 (PST) Received: by 10.223.75.146 with HTTP; Thu, 23 Feb 2012 15:39:18 -0800 (PST) In-Reply-To: References: <4F455C96.50706@gmail.com> <4F455E91.2060408@alliantinternet.com> <028001ccf1ab$0b200050$216000f0$@alliantinternet.com> <4F457517.7050901@alliantinternet.com> <028d01ccf230$91d79b00$b586d100$@alliantinternet.com> <4F4686C6.2040207@sugarcrm.com> <4F46BE01.7030007@gmail.com> <4F46C93A.1010108@gmail.com> Date: Thu, 23 Feb 2012 15:39:18 -0800 Message-ID: To: =?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?= Cc: John LeSueur , Stas Malyshev , Anthony Ferrara , Dmitri Snytkine , Sebastian Krebs , PHP internals list Content-Type: multipart/alternative; boundary=f46d04428e5c21998304b9aa278e Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: kris.craig@gmail.com (Kris Craig) --f46d04428e5c21998304b9aa278e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Err typo correction: In my "what if" scenario, I meant to say, "what if dynamic function A makes a call to *static* function B". --Kris 2012/2/23 Kris Craig > Hmm that's a fascinating idea! So, and please correct me if I'm wrong, > you're saying that it might be a better approach to determine strict vs. > dynamic typing on a per file or function basis instead of on a per stack > basis? In other words, blah.php could contain two functions, one using > strict typing and the other using traditional dynamic typing? > > Theoretically, I think that approach could work. Perhaps we'd have it > specified in the function declaration itself; i.e. "function whatever( > $text, $number )" would be a traditional, dynamically-typed PHP function, > whereas "strict function whatever( string $text, int $number )" would use > strict typing. > > The obvious question then would be, what if dynamic function A makes a > call to dynamic function B, passing to it a dynamically-typed variable? > There are three viable approaches that come to mind: This count not be > allowed; this could be allowed but only if the variables being passed to > function B are cast first (i.e. B( (string) $text, (int) $number );); or, > this could be allowed without casting, in which case PHP would attempt to > pass the variable and then throw an exception if it cannot be parsed as t= he > required type. Personally, my vote would be for Option 2. > > > I know this would be potentially confusing to people who are used to the > existing language structure, but it's also worth noting that PHP has > already changed quite a bit over the years and we've all managed to adapt= . > I'm thinking this would be perfect for PHP 6, since it would not be at al= l > unreasonable to assume that there would be significant language changes > that might require a slight learning curve at first, just as PHP 4 and 5 > did. > > This is perhaps the most common complaint I hear about PHP. There are > many programmers out there who think we're out of our minds (or just plai= n > lazy) for not acting on this. I'm not one of them, mind you, but I can > certainly see why they'd think that looking from the outside. I think it > would be really awesome if we decided to finally tackle this head-on, > despite the obvious discomfort that it would bring in the short-term; > though I think much of that could be mitigated if we simply targetted thi= s > for PHP 6. > > --Kris > > > > 2012/2/23 =C1ngel Gonz=E1lez > >> On 23/02/12 23:49, Kris Craig wrote: >> > Yeah I agree, that was one of the things I listed under >> > "disadvantages" lol. >> > >> > I guess my question is: Does this constitute a prohibitive problem, >> > or is it something that we can stomach? >> > >> > I mean, if you think about it, that's really what we're talking about >> > anyway, right? After all, when you're writing any application, you're >> > either going to be writing it with strict typing or you're going to be >> > writing it with dynamic typing. The only difference here is that >> > coders with either preference will both find PHP accommodating to >> > their style. >> > >> > >> > Similarly, a somewhat weaker argument could be made that, in PHP 5, >> > you're either coding for procedural design or for OO design >> > (technically you could do both, but I wouldn't wanna touch that >> > codebase with a ten foot poll lol). The only difference here is that >> > there would be a config setting to tell the interpreter which is which= . >> > >> > --Kris >> I think you would get developers coding for strict, and hostings set to >> weak. Makes more sense to have it as a per file / per function >> attribute, so the author can choose if they want the values passed to it >> to be coerced or act as if they were doing a manual check and throwing >> an exception. >> >> > --f46d04428e5c21998304b9aa278e--