Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92344 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75803 invoked from network); 15 Apr 2016 17:16:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2016 17:16:33 -0000 Authentication-Results: pb1.pair.com header.from=cornelius.howl@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cornelius.howl@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.65 as permitted sender) X-PHP-List-Original-Sender: cornelius.howl@gmail.com X-Host-Fingerprint: 209.85.218.65 mail-oi0-f65.google.com Received: from [209.85.218.65] ([209.85.218.65:36114] helo=mail-oi0-f65.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0C/C7-29891-0F121175 for ; Fri, 15 Apr 2016 13:16:33 -0400 Received: by mail-oi0-f65.google.com with SMTP id v126so14526083oia.3 for ; Fri, 15 Apr 2016 10:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=fe/B1NcrZ2b4G/LS/WU5vAG0RXJGEwvcieg05PQKQ3g=; b=lYQi4IuJI33opA7qYMzDXSfoZkz8qDxhkoamcD9M4u0hxwjfOC8wkZcbVR5gds/Sdb F6Yf/0MAfKc9QD1Noa1ynVGO06fGcZyoeuU8AH9vCOqFmg/puhn6483h+y/z45TRkG8R kO3YaT9eQh/qJbt4IM3zGGphD9y+cNk21QlQqhw3iOkI73U0G6hYha78S8rGJQaB/iwv SizfGjXdNYczbDwUQduR9gAE7r7IkIkl8MNqvDglI5izq1FAg916iYNylN6k1dw8uYK/ vG9AaTJJlDQAsVFPoWNHCXPr0Z4nT32UZMEp9Sl9e4I0EY86shB/rlctVpsJSdmUtcLo Sosg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=fe/B1NcrZ2b4G/LS/WU5vAG0RXJGEwvcieg05PQKQ3g=; b=TWSfjZtZO/ou8wjXb/oehUIvD3Zdgck3bhMCON6w4fJhzUhRrg9CAk2KmujC7ZpnSj KhPiVI3VH/NL4k+Ybfw9w58YaX/YKf5zT17JSgufKgRNKc8dcPbTIm4Eui+GiGqubOpF wJNF5N2uhR27uNAVRO1Nn2YFeJKQnJxa1J6juTwg92qeMRYS17MWbV+jhqydziK0f4uc eult2P8EmigJ290iAVLH55bEurSi3MMMHufGUWAgzZGbRR4aH8c3brW1422i576Nwv0j JZf5ICX9dwmCLYERfatzHzXZMEbnIKf8dX5UgFWccehe51At5itJqgGvDlKx6p1jUarc Dg7g== X-Gm-Message-State: AOPr4FWccv6jm57a+yEW6+iOz0DUxabf255Mg8ilN29p70GxzoHT9+MC1PVjv1NxnbHPOKkbSo2OAfdRyj7L4Q== MIME-Version: 1.0 X-Received: by 10.202.83.75 with SMTP id h72mr10651450oib.121.1460740590283; Fri, 15 Apr 2016 10:16:30 -0700 (PDT) Received: by 10.157.7.194 with HTTP; Fri, 15 Apr 2016 10:16:30 -0700 (PDT) In-Reply-To: <20.53.29891.17401175@pb1.pair.com> 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> <20.53.29891.17401175@pb1.pair.com> Date: Sat, 16 Apr 2016 01:16:30 +0800 Message-ID: To: Andrea Faulds Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113de8e4fe5e450530892b15 Subject: Re: [PHP-DEV] Improving PHP's type system From: cornelius.howl@gmail.com (Lin Yo-An) --001a113de8e4fe5e450530892b15 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Andrea Faulds =E6=96=BC 2016=E5=B9=B44=E6=9C=8815=E6=97=A5 =E6= =98=9F=E6=9C=9F=E4=BA=94=E5=AF=AB=E9=81=93=EF=BC=9A > > > This is something that particularly concerns me about union types, in tha= t > they reduce type safety. If you have a union type of Foo|Bar for some > variable, then the set of methods you can call on that variable is actual= ly > the intersection, not the union, of the set of methods you can call on Fo= o > and Bar. Which, unless those two classes share some interface, is probabl= y > an empty set. So there's nothing you can actually do safely with it witho= ut > doing checks within the body of the function, and if you're doing that, > then why do we have a type declaration? It's only barely more useful than > omitting a type declaration at all; type declarations are supposed to > prevent you needing to check. On the other hand, if the two classes share > some methods, then either there's an interface you can already use here, = or > you can create one. Either way, you don't need a union type. +1 I agree. Language like Golang use interface to intersect the method calls, I think that's better. > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Sent from Gmail Mobile --001a113de8e4fe5e450530892b15--