Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77178 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72288 invoked from network); 14 Sep 2014 12:08:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Sep 2014 12:08:53 -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.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:41759] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/81-53483-45585145 for ; Sun, 14 Sep 2014 08:08:53 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 7F5DDB0008A; Sun, 14 Sep 2014 08:08:49 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id hXOs4r5Gjo9E; Sun, 14 Sep 2014 08:08:49 -0400 (EDT) Received: from [137.50.30.19] (oa-res-30-19.wireless.abdn.ac.uk [137.50.30.19]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id D1226B0007B; Sun, 14 Sep 2014 08:08:48 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable References: <6893A97A-EC4C-4124-B804-96E2A26B953F@ajf.me> <20140914000718.GB14312@phcomp.co.uk> <3177B936-50C1-4E5D-8687-FD235C72B411@ajf.me> <54153692.7050500@sugarcrm.com> In-Reply-To: <54153692.7050500@sugarcrm.com> Message-ID: <9CE963B0-E624-4267-BC2A-0F8D1F985DAE@ajf.me> Date: Sun, 14 Sep 2014 13:08:03 +0100 Cc: "internals@lists.php.net" To: Stas Malyshev Mime-Version: 1.0 (1.0) X-Mailer: iPhone Mail (11D257) Subject: Re: [PHP-DEV] [VOTE][RFC] Scalar Type Hinting with Cast From: ajf@ajf.me (Andrea Faulds) > On 14 Sep 2014, at 07:32, Stas Malyshev wrote: >=20 > Calling this "scalar type hinting with cast" when it doesn't actually > cast in wide variety of cases sounds a bit misleading to me. It should > be called "scalar type checking with restricted casting" or something > like that. I'd agree it's not the best name. This is mainly a decision to make when thi= s is documented or added to the language spec. If we change this thing's nam= e, we should perhaps stop calling typed parameters 'type hints'. > I would also ask to clean up an RFC a bit and to clarify which of the > proposed choices and "possible changes" are actually being voted for > when somebody votes "yes". The vote would be for the RFC as it is. Possible changes are things in the R= FC I was uncertain on. I might hold votes on some of them, actually. > In any case, I call everybody to vote against this RFC in this form, > since it introduces inconsistency between internal and user functions > and makes PHP have two different arbitrary sets of rules for implicit > conversions, and this can not be good for PHP. I had abandoned the RFC for this reason. However I gave up trying to improve= zpp and make it consistent with user land hints, or adding user land hints w= hich match zpp. The problem is that we *can't* be consistent. Internal functions already liv= e in this completely different world from user land functions. Nullability i= s handled differently. They use implicit casts in places as if they were use= r land functions with no parameter types at all. In other places they have s= trongly typed parameters. If they are passed invalid data, they usually just= return NULL and emit a warning, though this depends on the function. User l= and functions, by contrast, will emit a recoverable error if the wrong type i= s passed. To make these two consistent would require massive backwards-compa= tibility breaks. If we're just talking about casting, then this proposal does not alter casti= ng behaviour, in fact I've been very careful not to touch it. It does, howev= er, only accept a subset of the values zpp usually does. This is because it i= s a compromise between strict and weak parameter typing. While I understand y= ou might like it to be fully weak like zpp, many userland developers are in f= avour of something stricter, thus the compromise. Unlike zpp's rules, at lea= st these rules are clearly specified and prevent data loss. Thanks! -- Andrea Faulds http://ajf.me/=