Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58005 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4507 invoked from network); 24 Feb 2012 18:35:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2012 18:35:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; 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:35929] helo=mail-ww0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/93-17132-D68D74F4 for ; Fri, 24 Feb 2012 13:35:26 -0500 Received: by wgbdq12 with SMTP id dq12so2209818wgb.11 for ; Fri, 24 Feb 2012 10:35:22 -0800 (PST) Received-SPF: pass (google.com: domain of kris.craig@gmail.com designates 10.216.132.94 as permitted sender) client-ip=10.216.132.94; Authentication-Results: mr.google.com; spf=pass (google.com: domain of kris.craig@gmail.com designates 10.216.132.94 as permitted sender) smtp.mail=kris.craig@gmail.com; dkim=pass header.i=kris.craig@gmail.com Received: from mr.google.com ([10.216.132.94]) by 10.216.132.94 with SMTP id n72mr1909647wei.4.1330108522092 (num_hops = 1); Fri, 24 Feb 2012 10:35:22 -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=FaV+IydNxfHjeLIVvjch2Z6yx9kAsZU1UMT1z3Mk1+k=; b=WyXESS69E9cMNjVQvsPOXXMht87cuNDHE1aHtrYR6DgE0eAy6iufCsJ7XixCLL41om yoTxiB4an/37IpCD21FDy+cSpDo3hGSjkt5sFvuc3BF31eSkCu1v1K5aHOiicuwEhRxI jYzFIhSItwjHDnub/RBSm9zwio3eR0U/nd4aA= MIME-Version: 1.0 Received: by 10.216.132.94 with SMTP id n72mr1531200wei.4.1330108521906; Fri, 24 Feb 2012 10:35:21 -0800 (PST) Received: by 10.223.75.146 with HTTP; Fri, 24 Feb 2012 10:35:21 -0800 (PST) In-Reply-To: <4F47B2DC.30909@gmail.com> 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> <4F47B2DC.30909@gmail.com> Date: Fri, 24 Feb 2012 10:35:21 -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=0016e6da7d64f6044604b9ba05b5 Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: kris.craig@gmail.com (Kris Craig) --0016e6da7d64f6044604b9ba05b5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Could you elaborate on that a little? I.e. "as an interface for the call". I'm not sure what you mean by that. If you could provide a quick example, that would be awesome! =3D) --Kris 2012/2/24 =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). > > --0016e6da7d64f6044604b9ba05b5--