Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75449 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64793 invoked from network); 14 Jul 2014 13:29:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 13:29:00 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.199 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.199 imap11-2.ox.privateemail.com Received: from [192.64.116.199] ([192.64.116.199:45893] helo=imap11-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/C3-43645-A1BD3C35 for ; Mon, 14 Jul 2014 09:29:00 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id DA7DB8800FD; Mon, 14 Jul 2014 09:28:55 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id hxbbHBF1ETf2; Mon, 14 Jul 2014 09:28:55 -0400 (EDT) Received: from [192.168.0.15] (unknown [90.210.122.167]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 6EA1F8800F2; Mon, 14 Jul 2014 09:28:54 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: Date: Mon, 14 Jul 2014 14:28:51 +0100 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <16D48604-0C0A-4613-91A4-21392E3A2636@ajf.me> To: Alexey Zakhlestin X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: ajf@ajf.me (Andrea Faulds) On 14 Jul 2014, at 14:12, Alexey Zakhlestin wrote: > I don=92t think that "scalar casts=94 should do any additional = error-catching. they target a very different usecase. > It shouldn=92t guarantee correctness of the whole program. It should = guarantee that variable types are fixed inside of function. That is exactly what is being proposed though. People (including Anthony = himself, along with other proposals) have previously suggested type = hints which just casted. However, I don=92t think this is terribly = useful. You can already do that really easily (`$foo =3D (int)$foo;`), = and it=92s too lenient; the non-scalar type hints are useful because = they validate your types, and the scalar ones, while casting, should = validate to a degree. > In my opinion, this patch should act 100% similar to zpp. > And if, at some later point zpp-behaviour changes similar change = should happen to userland "scalar casts=94 Keeping close to zpp would be nice, but zpp=92s behaviour isn=92t always = the most sensible and useful one, but we should try to keep somewhat = close to it. > Some people talk about inconsistency, which is introduced by reusing = same syntax for "strict parameter types" and "scalar parameter casts=94. = There=92s some truth there. > Let=92s use different syntax. >=20 > This might work: >=20 > function foo((int) $a) > { > var_dump($a); > } >=20 > I would read it as declaration-level casting That has already been proposed. That is not this proposal. I=92d suggest = you read back in this thread; I=92ve previously explained my issues with = just casting with no validation, pure strict type hints, why it=92s fine = to re=FCse the syntax, and linked to Nikita Popov=92s blog post on the = subject. -- Andrea Faulds http://ajf.me/