Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82924 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28223 invoked from network); 17 Feb 2015 05:48:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2015 05:48:12 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.217.178 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.217.178 mail-lb0-f178.google.com Received: from [209.85.217.178] ([209.85.217.178:37126] helo=mail-lb0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A0/90-24654-A16D2E45 for ; Tue, 17 Feb 2015 00:48:11 -0500 Received: by lbvn10 with SMTP id n10so2524815lbv.4 for ; Mon, 16 Feb 2015 21:48:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=nAATyv8B64mkkSo4veI/MAHUrr6yNTUFxDoUQNxiP9w=; b=CaRGe8P443VM08KpXEfmk57jzE9zhCZuu5+szScfqTooqGuYvtV2COXq7mwGiWoTpj 9rnK81IfMZdewSkfAb2yqfB0UQazm1VJvvcD4mpcpX5NS+wi90NSEWpaE9v8HCPGXOdI hRenvgSq0dKkEymmijmn6CvX69ZBrKiWA8GpJ4lfuyUuWKvCNpNULpaeQ70KF/lnPKAX Ch+5Sl0XODvBK0uF18dem3BzFgmAy8rFbKx/Tb32PpnA8Bq7Ps/emyO3VDbMQPkpj1Z/ 1dg7sfny9rV25z6mD+JDMMwyGw87yMDAvgwrNsOidhoQ8jjVeQDqSH4N2HHSn8B79rJv oF7w== X-Gm-Message-State: ALoCoQk/DNuYGQTw/AYf0vPlKZx1yuSNpgP+wa0XxH8025dLeJbGrOzazjpSOFTjzqWCa7njj9GE MIME-Version: 1.0 X-Received: by 10.153.11.130 with SMTP id ei2mr18629672lad.53.1424152087697; Mon, 16 Feb 2015 21:48:07 -0800 (PST) Sender: php@golemon.com Received: by 10.112.126.65 with HTTP; Mon, 16 Feb 2015 21:48:07 -0800 (PST) X-Originating-IP: [199.201.64.2] In-Reply-To: <54E2AD88.6040206@lerdorf.com> References: <011801d04a07$83ab1c00$8b015400$@php.net> <016f01d04a3a$e9183220$bb489660$@php.net> <54E290E5.3020508@lerdorf.com> <54E2AD88.6040206@lerdorf.com> Date: Mon, 16 Feb 2015 21:48:07 -0800 X-Google-Sender-Auth: e9twFTfdjuifFaiIccH8gmgn2S0 Message-ID: To: Rasmus Lerdorf Cc: francois@php.net, Philip Sturgeon , Arvids Godjuks , Jefferson Gonzalez , Rowan Collins , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Reviving scalar type hints From: pollita@php.net (Sara Golemon) On Mon, Feb 16, 2015 at 6:55 PM, Rasmus Lerdorf wrote: > I would very much like it to be my problem how my API is exposed to a > user. At the very least I should have as much control over an API > written in C as one written in PHP. > And you have that control. You expose number_format() as taking a float, and it does, in weak and strict modes alike. > Currently with this RFC it is not > the case and worse, it is retroactively changing an existing set of > functions to be all-strict when this mode is turned on. Even with strict > mode enabled, userspace is not retroactively turned strict and you can > slowly transition your API to be strict by adding appropriate strict > types in a controlled fashion. > That's a dubious distinction. The "special" treatment of internal functions is due to them having types defined. Of course userspace functions don't become immediately strict since they don't automatically have types. > And this fact is quickly glossed over to the point where I believe a lot > of people didn't even realize that they were voting for a retroactive > all-strict internal API. But hopefully I am wrong on that point. > It's presumptive to assume you know what people are basing their votes on. You're better than that. >> We can sigh and tut about this not being "the PHP way", but the script >> author was the one who chose to enter into a tight contract, and the >> script author, not you, is the one who should have that authority over >> their own application. > > I find this view way too extreme. > You find giving authority over an application to the application author too extreme? > Not everything is this black and white in the real world. > We have to be really careful that we don't give the > illusion of better while we make things worse for people. In the real > world, you know for a fact that people are going to force-cast stuff and > they aren't necessarily going to be very careful about it. > THIS point I agree with in principle. Some developers are going to misuse this feature. That's true of every feature. It was true of goto, it's true of the input filter extension, it's true of PDO prepared statements. People use stuff the wrong way. That doesn't mean we should sacrifice functionality for everyone. > Right, but they will want to start using strict, or else what are we > even talking about? And as soon as they do that string that comes back > from their ORM and passed to number_format() now needs to be dealt with > somehow. I'll bet you a Tim Horton's doughnut that a depressingly high > percentage of people will simply toss a (float) cast on it and move on > and by doing so they have made their application worse. > And a hearteningly high percentage will use it the right way. I'll buy you that doughnut and have one myself. >> Again, you're assuming a single method call in a vacuum. Is it >> possible that the kind of script author who is turning on strict >> typing might, in fact, be strict in the rest of their application? >> Might, in fact, not try to pass a resource into a function expecting >> float because they have the tools of strict typing available to them? > > That's a lot of assumptions. > It's one assumption. That there exists a population of PHP developers who actually know how to program. I'm sorry you don't think that's the case. >> So let's talk compromise. >> Would leaving internal functions out of the picture at this stage >> change you mind? This is effectively what Hack does, internal >> functions are explicitly marked as "coercible". >> Would a tri-state option make sense? ('weak-all', >> 'strict-user/weak-internal', 'strict-all') >> How do we get from here to something you would like? > > So in Hack you didn't think it was a good idea to change the internal > and extension api either? Was the reasoning similar to mine? Did you > agree with the reason then but not now? > First, I'd like to note that you seem to be ignoring my question. ** How do we get from here to something you would like? Second, I should clarify that while the HHVM runtime performs coersion, the hack type checker is strict. So my original statement was inaccurate. As far as hack is concerned, it's simply strict. Period. Third, Not everything done in hack is in line with what *I* would like. Don't mistake me for hack. -Sara