Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93741 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71578 invoked from network); 3 Jun 2016 10:30:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jun 2016 10:30:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.41 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.41 mail-wm0-f41.google.com Received: from [74.125.82.41] ([74.125.82.41:38786] helo=mail-wm0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/91-56709-74C51575 for ; Fri, 03 Jun 2016 06:30:32 -0400 Received: by mail-wm0-f41.google.com with SMTP id a20so100465484wma.1 for ; Fri, 03 Jun 2016 03:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:to:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=fzLoZVh4pPs6hYvrz/7XkdgrWu98Nn9jf6TE91ysKx4=; b=DsxDe68kDemwmCC0n8coqLVmlC3PdzETFmKB1qpLuc13yS8p9oZjS763iEBB/aq8A6 vgJeSFgoSWvFhf/3gva/7zqrBqnQx5FIOahPr6GBG5ICM8x9xO+/Cco0SCWroPwgey4V PA6xSV4hgpa7ny1AQ4Q0uh7lt+QuYXH+MU7qPOJRO0bE/OygezJA2buKo7ePhDI2VhyA NJTmpjXmwBU/kHSYdDndcs+nooxKMmgvW0itYuB14fulgH9WgGOhNOzgvzW7dXHH5tsc lyVLAU2OR/N7TK4mm7lb8tzg2JBnmIZqujTml1Tfet+f1f+SGy1GglsHfXhq/HWKt2Uu 2jfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:references:from:to:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=fzLoZVh4pPs6hYvrz/7XkdgrWu98Nn9jf6TE91ysKx4=; b=ZBkGBc8n8Jph4gKgf0mwh7SIiI5wydWwN0JZUxGU+vl3tsIdPPOL4PJu6nkqhRjgHU yTzCKUEDSl686uslelj+skvDjtQ7va2gLMbDV18PE4H5klmTaGgQ4ZV5aVefNqZB+m0Q 6SuI46uWDbqEqWNWSg0XZZ2HNMOI1iab5hf9AOHrY5Bi6VVw/vGz2T152BkhP/J2YIsL kG7oDwWR1Hvvdk7SjJbn6YmFnUufvA+O3vvXhNHGM32+RZiIMWtWq5AfFMdIUqVJ3EeZ KicFwJWtVYMzluaC1nZlWr4okwEg0x864JwOFDji4FAkxhRN1TlqfoYd+wlhlD+wwJCv ZZVA== X-Gm-Message-State: ALyK8tJ8915sbY7+V+WmOfv7Jj+N0k8T89ICAJ6ygZJu0WpRkcOD7wpOdwl7OfRDwuWijw== X-Received: by 10.194.42.69 with SMTP id m5mr2785974wjl.89.1464949829381; Fri, 03 Jun 2016 03:30:29 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id h14sm45088103wme.1.2016.06.03.03.30.28 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Jun 2016 03:30:28 -0700 (PDT) References: <0A.C5.62101.1C860575@pb1.pair.com> <68b821ac-d71f-4be5-8dca-ae94db332630@gmail.com> <20160603101659.D466A1A81FC5@dd1730.kasserver.com> To: internals@lists.php.net Message-ID: <6d448fd8-8fda-d795-accb-6b96cd128ccd@gmail.com> Date: Fri, 3 Jun 2016 11:28:04 +0100 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: <20160603101659.D466A1A81FC5@dd1730.kasserver.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: [RFC] [PRE-VOTE] Union types From: rowan.collins@gmail.com (Rowan Collins) On 03/06/2016 11:16, Thomas Bley wrote: > why not try all types weakly from left to right in weak mode? > Rule: if type check would give a fatal error for a type, try next type. This is what I suggested, but Bob is insistent that weak mode should always select the same type as strict mode where there is a valid strict match, which I guess makes sense. A strict left-to-right check violates that: function i(string | int $x) { echo gettype($x); } i(10); // string in weak mode, int in strict mode function j(int | string $x) { echo gettype($x); } j('10'); // int in weak mode, string in strict mode The main complication that I haven't quite got my head round yet is the fact that an int->float coercion is allowed in strict mode. So to be consistent, weak mode needs to privilege that cast: function k(string | float $x) { echo gettype($x); } k(10); // float But in other cases it doesn't seem sensible to privilege float over string: function l(string | float $x) { echo gettype($x); } l("1.5a"); // I would expect string, but float would succeed if attempted Regards, -- Rowan Collins [IMSoP]