Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75417 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65491 invoked from network); 13 Jul 2014 15:29:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jul 2014 15:29:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.182 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.192.182 mail-pd0-f182.google.com Received: from [209.85.192.182] ([209.85.192.182:57756] helo=mail-pd0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/C9-16748-CE5A2C35 for ; Sun, 13 Jul 2014 11:29:49 -0400 Received: by mail-pd0-f182.google.com with SMTP id fp1so1040261pdb.41 for ; Sun, 13 Jul 2014 08:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=68s+Ayvn3HteLqGum+MjdXscQgfk2kCIQezv/Q6WPCA=; b=jUdi90unfKreVXWyeV2wv22a/pbkJScgDOTWk4NTwhRnSdNt33wSri68cjOcxOR1kp hrw2RH/AGaccVssUYT/D2GQBIazfJTPgJ5AG8mbHKr9TJ16hZDgouhed0sso/2a9gSPN CI39CYUgew6Fi7BjAxHY88N7NzLAXkAJPVsYc2ZK46L3BLKs3lUP0ndXF7ADi2FR3Fxe yhcKgFNoTFV1THKAmhyaGpSOXAV3cKKxdJngj2JLZZqicT+/xRrvD1sxFeU9ZuvzetHJ P1c2FddXGnIOJjx8zVUqlt3Siuts+IL/lDsEiz+3wNIpFUrmDT8dlPuiwOfHUQuSJIwV EvuQ== X-Received: by 10.70.127.163 with SMTP id nh3mr1068280pdb.139.1405265385990; Sun, 13 Jul 2014 08:29:45 -0700 (PDT) Received: from tjerks-imac.gateway.2wire.net (bb121-7-198-24.singnet.com.sg. [121.7.198.24]) by mx.google.com with ESMTPSA id q6sm2601768pdp.5.2014.07.13.08.29.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 13 Jul 2014 08:29:45 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: <53C2A2F7.1000806@gmail.com> Date: Sun, 13 Jul 2014 23:29:42 +0800 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <61427066-434A-416B-A7A9-6CF7582D3D8A@gmail.com> References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <027E65EF-C4FC-474C-92BB-D99EFADDEEED@ajf.me> <53C29EE4.3090808@gmail.com> <53C2A2F7.1000806@gmail.com> To: Rowan Collins X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: tjerk.meesters@gmail.com (Tjerk Meesters) On 13 Jul, 2014, at 11:17 pm, Rowan Collins = wrote: > On 13/07/2014 15:59, Jocelyn Fournier wrote: >> =46rom my point of view, if the type annotations are doing implicit = cast (with or without E_NOTICE/E_STRICT warning), they should behave = exactly the same than an explicit cast. If it behaves differently, I'll = be really difficult for a developer to guess what will be the PHP = behaviour with this new syntax. >=20 > The problem is, in PHP an explicit type cast never fails - (int)'abc' = simply gives you the value 0, not an error. If you let scalar typehints = just generate unchecked casts, we'd have this: >=20 > wants_object(object $foo) { var_dump($foo); } > wants_int(int $foo) { var_dump($foo); } >=20 > wants_object('abc'); // fails with E_RECOVERABLE_ERROR > wants_int('abc'); // succeeds and prints int(0) Depending on the final implementation, the latter may raise a notice = about information loss. >=20 >=20 > That seems both inconsistent and less useful than a hybrid juggling + = validation approach. While this is indeed inconsistent, scalars and objects aren=92t the same = thing, though, and I think it=92s okay to treat them differently. >=20 > --=20 > Rowan Collins > [IMSoP] >=20 >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20