Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58197 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65295 invoked from network); 27 Feb 2012 21:24:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2012 21:24:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.49 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.49 mail-qw0-f49.google.com Received: from [209.85.216.49] ([209.85.216.49:57232] helo=mail-qw0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/A7-29394-9A4FB4F4 for ; Mon, 27 Feb 2012 16:24:57 -0500 Received: by qafi29 with SMTP id i29so480047qaf.8 for ; Mon, 27 Feb 2012 13:24:54 -0800 (PST) Received-SPF: pass (google.com: domain of tyra3l@gmail.com designates 10.224.212.134 as permitted sender) client-ip=10.224.212.134; Authentication-Results: mr.google.com; spf=pass (google.com: domain of tyra3l@gmail.com designates 10.224.212.134 as permitted sender) smtp.mail=tyra3l@gmail.com; dkim=pass header.i=tyra3l@gmail.com Received: from mr.google.com ([10.224.212.134]) by 10.224.212.134 with SMTP id gs6mr12546953qab.32.1330377894445 (num_hops = 1); Mon, 27 Feb 2012 13:24:54 -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=4GixsRr3w4Yydxe/cgQMqfPJABYAXMOEZ0HP7l3/dMc=; b=bzBXJ2gcgO8k2mkCZfBXI9hmkVZ5krENxmdlwbB8wB7mafm8tzcnUcL4QM2+k7xIRw geE8amfFGsHfZsdj/q9GiXt8Im0XqEEZkl8au8yA8Zf2BPMMFZwE/iM2TPuv7S6N0CT/ err7A1kktIgytP8/2X7jJGPVXGR0BJnqT8G5M= MIME-Version: 1.0 Received: by 10.224.212.134 with SMTP id gs6mr10552149qab.32.1330377894362; Mon, 27 Feb 2012 13:24:54 -0800 (PST) Received: by 10.229.30.205 with HTTP; Mon, 27 Feb 2012 13:24:54 -0800 (PST) In-Reply-To: References: <1330357150.2159.30.camel@guybrush> Date: Mon, 27 Feb 2012 22:24:54 +0100 Message-ID: To: Kris Craig Cc: Anthony Ferrara , Michael Morris , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=20cf300fac4dcf7dd804b9f8bd29 Subject: Re: [PHP-DEV] Scalar type hinting From: tyra3l@gmail.com (Ferenc Kovacs) --20cf300fac4dcf7dd804b9f8bd29 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Feb 27, 2012 at 8:15 PM, Kris Craig wrote: > Now, to rewind a bit past the latest chunk of "I hate this idea" posts...= . > > I'd like to suggest a new term: "strong". > I think it would be better if we could not introduce terms for new definition if that term is already used in the vocabulary for type systems: http://en.wikipedia.org/wiki/Strong_typing > > This term would be similar to "weak", except with a few key differences: > > - Weak would behave very much like Arvids suggested in his earlier > post; i.e. if the variable is an integer but you pass a string (like "= aaa") > to it, a warning would be thrown and PHP would attempt to convert it (= i.e. > it would become 1). > > why would "aaa" turn to 1? it would be 0 by the php type juggling rules. > > - Strong, on the other hand, would throw a fatal error if you > attempted to pass an incompatible value to an array. Or, to put it an= other > way, if the "converted" value does not match the original value. For > example, if we're assigning "aaa" to an integer, that would convert to= 1; > and, since "1" !=3D "aaa", a fatal error would be thrown. On the othe= r hand, > if you were to pass the string "1" to that integer variable, it would > convert to 1; and, since "1" =3D=3D 1, there wouldn't be a problem. > > same error here, it seems that it isn't the typo. putting that aside: so you say that the type checking would behave the same was as does currently the =3D=3D and =3D=3D=3D operator. > > - In both instances, if the converted value matches the original (i.e. > "1" =3D=3D 1), no warning error would be displayed. Should it perhaps= display > a notice though? Or no error at all? I can think of reasonable argum= ents > on both sides of that question. > > I remember seeing that suggestion before, I think that it was proposed more than once, see http://marc.info/?l=3Dphp-internals&m=3D128159992610321&w=3D3 did you read that thread? --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --20cf300fac4dcf7dd804b9f8bd29--