Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92437 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98319 invoked from network); 19 Apr 2016 01:28:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Apr 2016 01:28:21 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.43 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.43 mail-pa0-f43.google.com Received: from [209.85.220.43] ([209.85.220.43:35205] helo=mail-pa0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/62-11975-4B985175 for ; Mon, 18 Apr 2016 21:28:21 -0400 Received: by mail-pa0-f43.google.com with SMTP id fs9so842099pac.2 for ; Mon, 18 Apr 2016 18:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=D2hFgOnVWvhcscsnOBTbKnJdz8Iwn7kjllmaMeK1emg=; b=uCn2TCAt/RXsnjhHGBa5MK2hsNgv+EWh7n+PPjS88dy9m9V3gppn0OI/MnzHvX1e/8 6O6AtI89hc/NJp208YMlz5XcRBQdRVNI0Wm+P4YTj5n+G+ZjcQUx73kxs0u5WEr8wooX yeByLRQqJnpbFvTX0RH0w2QBNSt4/x8CNACI3B3hR7CYJDpV+3+lXSr37VS0cOkPFt11 l3yfrZgHzgcwgocIuOd+0dtvIxKKzzJbnhySF//X99DM8lVPB93dXchXS1jFOz+zq3Jd nZaBeQzaaGeLgUj3IRproKh6OZjuBdZ7I7sq3iX9aT+DfqzachFZCQwKVf1eHXqLXYFh t9xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=D2hFgOnVWvhcscsnOBTbKnJdz8Iwn7kjllmaMeK1emg=; b=gE3L/f48TkUWlpA2aRXBQjgt/q6VcDR8cxPBuuzVkYEQiOLjl1G+aDikQz1CACudjd lrf17nzSQIsih4VNOOz4xBByARSyRwtd/nlU9bCUHdy9GHMDwyRpxaTgwsCXPY8yzzGA SdHCNDWmLLDfn91XevkcaGWADdkxOCPiK6Qy/t2+VcdaYtGl58edl3wi1NP1kv1yykJ1 CnVzZvQ2l6myGz8I5jeihYNFhebgGPxZ3isz1Ypj8YWBTHafdf2MiBiDYgykPC2+GDeJ PZbcvWaic7QhmnhE5IB0BRqY9hZmNDEbmTmRXbizjfih1BS+bqalq8fP+gYvnGtx8240 cvKg== X-Gm-Message-State: AOPr4FV5M0ojdcD3DeOwTEr/bobx5Rd1I8yihP3p72C6qhRoHgJY+3CW4u1eccDJstyopQ== X-Received: by 10.67.8.100 with SMTP id dj4mr371061pad.88.1461029298155; Mon, 18 Apr 2016 18:28:18 -0700 (PDT) Received: from Stas-Air.local (76-220-46-95.lightspeed.sntcca.sbcglobal.net. [76.220.46.95]) by smtp.gmail.com with ESMTPSA id a77sm40458030pfj.2.2016.04.18.18.28.16 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Apr 2016 18:28:16 -0700 (PDT) To: bishop@php.net References: <571581C7.7010901@gmail.com> Cc: PHP internals Message-ID: <571589AF.3090502@gmail.com> Date: Mon, 18 Apr 2016 18:28:15 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [VOTE] Catching Multiple Exception Types From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > It's about the perception of consistency. "Oh, I can do this! Neat:" > > function neat(Foo | Bar $a) { ... } You shouldn't be able to do this, because it makes no sense - why would a function accept two random types and only them? That's probably a bad design - it should be one type or two functions. > "But I can't do this? WTF?" > > catch (FooException | BarException $ex) { ... } But this makes total sense - you routinely catch more than one type of exceptions, just not you write it catch(Foo) ... catch(Bar...). You very rarely have functions that do exactly the same with two types, and only those. The usage is different. I do not think approach "it should look the same, no matter what the usage is" is right. > And vice-versa. The perception revolves around the fact that both appear > to be signatured, regardless of how they're implemented in the engine. But that's not what they do. Function says "I accept only parameter of this type, and it's an error if it's not". Catch says "I will process exception of this type, but if it's not, other catch clause may process it". You don't chain functions like that, but you do chain catch clauses. Again, different usage. -- Stas Malyshev smalyshev@gmail.com