Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58307 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8729 invoked from network); 28 Feb 2012 23:17:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2012 23:17:03 -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 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:42559] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/BF-36673-F606D4F4 for ; Tue, 28 Feb 2012 18:17:03 -0500 Received: by vbjk13 with SMTP id k13so2434834vbj.29 for ; Tue, 28 Feb 2012 15:17:00 -0800 (PST) Received-SPF: pass (google.com: domain of kris.craig@gmail.com designates 10.52.71.114 as permitted sender) client-ip=10.52.71.114; Authentication-Results: mr.google.com; spf=pass (google.com: domain of kris.craig@gmail.com designates 10.52.71.114 as permitted sender) smtp.mail=kris.craig@gmail.com; dkim=pass header.i=kris.craig@gmail.com Received: from mr.google.com ([10.52.71.114]) by 10.52.71.114 with SMTP id t18mr15300173vdu.88.1330471020879 (num_hops = 1); Tue, 28 Feb 2012 15:17:00 -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=nCOVR+dqq8Y9A1JTn0puQ+wrXsGa4FBjnl9ClvsOVz8=; b=DrlATrn3QJdKWeU30mnFCc+z/14CuidQp+ek2R3ZXu+zS1vBTSuYz81li94QvpX2N4 RVTyQLU4Ve7ilsa5EQyxFOePHWt7YXcKuNcYdr3zS6ybtV76t1b563NAjcxHHNEDpK4u kIZdMtRwh63CkySOdAaCTdFr3MR/zaKTijQFI= MIME-Version: 1.0 Received: by 10.52.71.114 with SMTP id t18mr12653025vdu.88.1330471020568; Tue, 28 Feb 2012 15:17:00 -0800 (PST) Received: by 10.52.91.5 with HTTP; Tue, 28 Feb 2012 15:17:00 -0800 (PST) In-Reply-To: References: <1330357150.2159.30.camel@guybrush> <693e15008681dfe7372eaea66214f8a8.squirrel@www.l-i-e.com> <4F4D5D44.5090307@developersdesk.com> Date: Tue, 28 Feb 2012 15:17:00 -0800 Message-ID: To: Michael Morris Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf3071d0d4909f3004ba0e6c87 Subject: Re: [PHP-DEV] Scalar type hinting From: kris.craig@gmail.com (Kris Craig) --20cf3071d0d4909f3004ba0e6c87 Content-Type: text/plain; charset=ISO-8859-1 +1 on that. However, I believe the coder should also have the option of determining whether this should be recoverable or not, just like they have a choice with regard to using "include" or "require" (one fails gracefully, the other terminates execution). That's where I think strong/weak could be very useful. Here's how I would do it: weak int $a = "House"; // Throws E_WARNING strong int $a = "House"; // Throws E_RECOVERABLE_ERROR In both cases, the error can be caught, which would mirror the flexibility in languages like C#. However, if the weak one isn't caught, the warning is thrown but the script proceeds as normal. If the strong one isn't caught, the script will terminate as if it was an E_ERROR. I think this would be the most sensible approach in terms of balancing simplicity and flexibility. --Kris On Tue, Feb 28, 2012 at 3:08 PM, Michael Morris wrote: > Agreed. If conversion can occur without data loss (that is, if the > value being assigned is == the value that actually IS assigned) then > no error should occur. > > So > > int $a = "1"; // no error. 1 == "1" so who cares? > int $a = 'House'; // error 0 != 'House', so this is a problem. > > Again, errors should only raise if the final value != source value. > > On Tue, Feb 28, 2012 at 6:03 PM, Rick WIdmer > wrote: > > On 2/28/2012 2:58 PM, Kris Craig wrote: > > > >> strong int $a = "1"; // Converts to 1. May or may not throw an error > (I'm > >> still on the fence). > > > > > > It this is an error, it is no longer PHP. > > > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --20cf3071d0d4909f3004ba0e6c87--