Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94008 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36154 invoked from network); 15 Jun 2016 13:20:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jun 2016 13:20:18 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.21 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.21 mout.gmx.net Received: from [212.227.17.21] ([212.227.17.21:55580] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/11-27860-F0651675 for ; Wed, 15 Jun 2016 09:20:16 -0400 Received: from [192.168.2.102] ([217.82.228.97]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MYwQh-1arOdg38tP-00ViRP; Wed, 15 Jun 2016 15:20:07 +0200 To: Levi Morrison , Zeev Suraski References: <8d26c709-2083-40ac-3bb5-cddc0ecef4bd@gmail.com> <6B3C4F2A-22D6-4004-9F14-5E43EA8AD52A@zend.com> <619DDA1B-0722-4487-B545-7EB7FDB2BE7C@zend.com> Cc: PHP internals Message-ID: Date: Wed, 15 Jun 2016 15:20:23 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:ztBqliShIEScKRsH8CaoPHy8/U5yQIwqobA+YeP85wYeVk9Hi5g qC50EgWFadD1OYrKR9Bz9PgKbuIUSqTVeJ/rqhpmk/eHnt6Be/5h4Il3bsHvFjNsjLG/eIH U3iyK7f3OnGanToHcBx2YYKjiFx+CkPat2psz7XsrsNo6p//lOBtIyJ/8vHm5DiFpiVtni0 nhNpqxM3s58bxsTt6vYxw== X-UI-Out-Filterresults: notjunk:1;V01:K0:UZTm7j36lFc=:YV6P0FVt38EksGiJ7sdGb5 Su9f+s0wZdxqDsDc6/hkbtQCd8rr97RCY5Bs6qxvjKmW19HkWQn3uoWwA57Xzt/rQ2T/m+ANS 9My7QCGPKrTgg7NICtmHBTXGWr4x3hARm5ZcrC0p0auRkNwegbR1oEIO0StVZUjvjoc+QEwRA w8sdBdYlMduSRzt7cM2ylBRZmbxSoqH0DtaoHNTU4j7qDXVub32gNalMplNNaCW0R4q1g2xyN IH5TFZe4Gvc27amvfhQKEhKwgiKu9Hx5IBXsKRQCQQglzdl2x/956RNXKbOkDG1G/4u90Y2T3 HcoUBIok0zh+FQCurcChsAcIVrSEs8DInCmL1JW/Bu1C0HJ/qyCSeFr9bgP8wv8S4Zl45KsvN aJVrq3LkqPzwz752dho+0M5Tq91Ydymt6YrjC67fIgwJq6Qwm48nN24e7eMpfxFtwbt+morVy O1moaJq/I38MEH3Wy8htQrR45LaSRjYVk6Cqyjc3Ffexcgf/TUVUi4x/77L6q8f9GHZoIIkFj waRIWal+CtBK8ovudoliGVLWVfmuq2oJr/91XveWYtYWq0F8RwDhWCseZdk38sea0Jzx3TTWG 0N5K3akUBqQF0x8cFKsQg3ilXDxHWNhbgjiLCHnC6botPNaAQwJEfsMgRw6+APeOU8gaP9kdb PQXrvJhRx8IvWbXwqnAcQAZVWkEbZfFV8mB8YDKkACmtX+Tv2w7Jh2voPB3EaIZS+PgyeFsKP SMXTthGJLmD53Y4h11yJN0mF1TfLXBdd0I99MpzHz36EMHQMRP3+qArV4Uws3CL8+wWpz+nRN /6AsR+s Subject: Re: [PHP-DEV] [RFC] [VOTE] Union types From: cmbecker69@gmx.de (Christoph Becker) On 15.06.2016 at 00:51, Levi Morrison wrote: > On Tue, Jun 14, 2016 at 2:43 PM, Zeev Suraski wrote: >> >> On 14 ביוני 2016, at 22:53, Levi Morrison wrote: >> >> I'm personally against Union types because it makes no sense for classes >> >> I've been over this before but I'll repeat it here for completeness: >> this is not true. >> >> There are more than enough constructs in PHP to handle all these use cases, >> and handle them nicely. We don't need specialized constructs for every use >> case. > > To clarify here, you are saying we don't need unions because they are > a special case, yes? But you previously stated you are in favor of > special casing the language types such as numeric? > > These are at odds. In my opinion, there have to be always compromises when designing a language for practical purposes. Theoretically, it would not even be necessary for PHP to have scalar types; everything could be done with (immutable) objects as well. However, we do have scalar types, and these are likely to stay, so it seems reasonable to me to add a few special cases to our type system covering this issue (say, Stringable, Iterable, numeric, Invokable). Adding union types as a general mechanism, on the other hand, adds a new level of complexity for the user which is orthogonal to the classical OO type system, at least when type definitions will be added, what I estimate will not take long, due to the verbose inline union typing. And that is easily going to get out of hand, because independent libraries might introduce their own LIB\numeric, for instance, potentially with slightly different definitions (e.g. with or without GMP). Finally, I don't consider |false a very reasonable thing, because the respective functions could return a nullable type as well, what would in my opinion be better anyway for the famous strpos(), which requests the position of $needle in $haystack, what should be either a numeric index or NULL (== not present). And at least built-in functions may also return NULL for wrong argument types, which would require to type their return values as X|false|null to be exact. -- Christoph M. Becker