Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92340 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65912 invoked from network); 15 Apr 2016 16:30:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2016 16:30:57 -0000 Authentication-Results: pb1.pair.com header.from=fsb@thefsb.org; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=fsb@thefsb.org; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain thefsb.org designates 173.203.187.67 as permitted sender) X-PHP-List-Original-Sender: fsb@thefsb.org X-Host-Fingerprint: 173.203.187.67 smtp67.iad3a.emailsrvr.com Linux 2.6 Received: from [173.203.187.67] ([173.203.187.67:49673] helo=smtp67.iad3a.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 31/C5-29891-04711175 for ; Fri, 15 Apr 2016 12:30:56 -0400 Received: from smtp25.relay.iad3a.emailsrvr.com (localhost.localdomain [127.0.0.1]) by smtp25.relay.iad3a.emailsrvr.com (SMTP Server) with ESMTP id D5F54180456; Fri, 15 Apr 2016 12:30:53 -0400 (EDT) X-Auth-ID: fsb@thefsb.org Received: by smtp25.relay.iad3a.emailsrvr.com (Authenticated sender: fsb-AT-thefsb.org) with ESMTPSA id BC8C7180453; Fri, 15 Apr 2016 12:30:53 -0400 (EDT) X-Sender-Id: fsb@thefsb.org Received: from yossy.local (c-66-30-62-12.hsd1.ma.comcast.net [66.30.62.12]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:587 (trex/5.5.4); Fri, 15 Apr 2016 12:30:53 -0400 To: internals@lists.php.net, Fleshgrinder References: <570E99AC.3090804@fleshgrinder.com> <570EA5EB.8090501@fleshgrinder.com> <570EAB0D.6080706@gmail.com> <570EB67E.8010908@garfieldtech.com> <5B147E88-CC0A-4CBC-A49D-C7FE3BF557C0@zend.com> <6F.C3.12455.94C5F075@pb1.pair.com> <20160414094440.GF19347@phcomp.co.uk> <570FD94F.90703@fleshgrinder.com> <570FE8A9.4020809@gmail.com> <570FEE98.1030401@fleshgrinder.com> Message-ID: <5711173D.1040500@thefsb.org> Date: Fri, 15 Apr 2016 12:30:53 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <570FEE98.1030401@fleshgrinder.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Improving PHP's type system From: fsb@thefsb.org (Tom Worster) On 4/14/16 3:25 PM, Fleshgrinder wrote: > On 4/14/2016 8:59 PM, Stanislav Malyshev wrote: >> >Hi! >> > >>> >>I don't know what is complicated about "string|Stringable" or "Foo|Bar" >>> >>since it is super self-explanatory. However, I find myself checking the >> > >> >It may be self-explanatory for you. It's much less self-explanatory for >> >somebody just starting to learn. It is also very dangerous - if it's >> >either Foo or Bar, can you call Foo::stuff on it or not? If it's string >> >or not string, can you call strlen on it? Etc., etc. It adds a lot of >> >cognitive load and complicates the whole picture. You may have a >> >specific use case where it is useful (which we have yet to see btw) but >> >please remember it's a language with literally millions of use cases and >> >users. >> > > Reduce assertions*, enhance self-documentation, making code more robust, I disagree here. I think our programs are more robust when programmers avoid passing mixed types and write more simple code instead. Hence I agree with Stas about the danger part. Union type hints are a hazard. Adding them to PHP as a new feature is like saying "here's a great new tool, pick it up and use it" but the tool is really a footgun. Tom