Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58000 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90289 invoked from network); 24 Feb 2012 15:50:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2012 15:50:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=keisial@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=keisial@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: keisial@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:36582] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/41-17132-DB1B74F4 for ; Fri, 24 Feb 2012 10:50:22 -0500 Received: by wibhm4 with SMTP id hm4so1802472wib.29 for ; Fri, 24 Feb 2012 07:50:18 -0800 (PST) Received-SPF: pass (google.com: domain of keisial@gmail.com designates 10.216.135.15 as permitted sender) client-ip=10.216.135.15; Authentication-Results: mr.google.com; spf=pass (google.com: domain of keisial@gmail.com designates 10.216.135.15 as permitted sender) smtp.mail=keisial@gmail.com; dkim=pass header.i=keisial@gmail.com Received: from mr.google.com ([10.216.135.15]) by 10.216.135.15 with SMTP id t15mr1612226wei.3.1330098618856 (num_hops = 1); Fri, 24 Feb 2012 07:50:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=ItNkyIWvuwFdjk4idf3g0pUNoJy1gRckhDFIVja34cE=; b=o6lU2GVmZiWQDdAeX1rQsfS+fIfRVPm5ZXNYqqvu3XPQcPm0aU+s/BOCkqJz7pbJtW xjsPALpN+Ft5/5YdNON1q2g0QNUZLVSgY2pPZkdY3O+BHovuO6HbFXdD7iza4z/SRvpO b1c830kzjSwzkQ4ZEjib261GS7CHc/sLHSwpY= Received: by 10.216.135.15 with SMTP id t15mr1301305wei.3.1330098618763; Fri, 24 Feb 2012 07:50:18 -0800 (PST) Received: from [192.168.1.26] (15.Red-83-55-231.dynamicIP.rima-tde.net. [83.55.231.15]) by mx.google.com with ESMTPS id ft8sm4261478wib.11.2012.02.24.07.50.15 (version=SSLv3 cipher=OTHER); Fri, 24 Feb 2012 07:50:17 -0800 (PST) Message-ID: <4F47B2DC.30909@gmail.com> Date: Fri, 24 Feb 2012 16:55:08 +0100 User-Agent: Thunderbird MIME-Version: 1.0 To: Kris Craig CC: John LeSueur , Stas Malyshev , Anthony Ferrara , Dmitri Snytkine , Sebastian Krebs , PHP internals list 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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: keisial@gmail.com (=?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?=) On 24/02/12 00:36, Kris Craig wrote: > 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? Yes. Two functions in the same file with different conventions may be a strange use case, I'd expect differences to come from eg. using two libraries, each with different 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. I'm not keen with that syntax, but that could be discussed. I remember something similar was already mentioned in another types thread, with ideasl like string! or string? to mark the types as strict or weak. > 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 the required type. Personally, my > vote would be for Option 2. I was envisioning it just as an interface for the call. Thus, if funtion A used strict or dynamic types would be irrelevant. You seem to be bringing up another option however, which is that funcion A could specify the behavior on functions it calls. It can look appealing, but I don't think that's desirable. After all, it's the callee interface what is important, not the kind of caller (you could have a setting to force an stricter behavior, but that seems more appropiate for an extension, like xdebug scream option).