Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96130 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13040 invoked from network); 24 Sep 2016 11:49:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Sep 2016 11:49:29 -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.45 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wm0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:38167] helo=mail-wm0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/20-11573-94866E75 for ; Sat, 24 Sep 2016 07:49:29 -0400 Received: by mail-wm0-f45.google.com with SMTP id l132so72041911wmf.1 for ; Sat, 24 Sep 2016 04:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:from:date:to:message-id; bh=EHBhrpxCsRZbshAlxIr8K4/+rJTQkMUgEI0uF2hU4F4=; b=zD4qhmd2KXR/JHtJh9z6TbCvQchJWUDrX7tgG1BpY2mt1irM2HNYrq8ce6Hi5DTWLE BFQTzZbB5IEzbrExPZmjr5TI17TwQF838LM8BwILyK2JsYy6n2kmyDbdC8NuboLTo6Iw kYDqDkuFBM3KoTBiAdCNpgE4NtAnZudfYcmpS9d/Ki24AtL2roIJyFh/AEWDtTwNjGh2 dQ7hsLLXOs4XsPDnwGe0tUKsHC8uB9mi8PBNWVeCjYuhZkQGLRyLd/DjRZVx84ktzF0g WF7ySdMYDCVaUtmueJQ43Qck56v9hTPQpFAd3HGqCRjkPD4QHolj2qDDKUBUjx4hCPPI qDQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:from:date:to:message-id; bh=EHBhrpxCsRZbshAlxIr8K4/+rJTQkMUgEI0uF2hU4F4=; b=Xt2uAXRaQZOJlrfH72DS5CKfwfGw7vI97xdYJhPGruqqHG+5CQGY1qeAa0rh/desXL FZuNhPQPIUH5CVYcKS+Q0XNSJkGLFP41jcu50BbIxgZ67BuU6L1WFyLkhDA3zsLDe42C ryMJBLiVFZRYcXS4Z8xx3H0kK4lznrJe/2J2y20klnmYmMrcqwiUxMP9QRifV9Z0oW38 A0qfXQZyNDrAkgozaFcuuUPU5IivREpsQBgCVKZUe4mhlNaf5QD3Gk6r3ZHooXW9OmMk LoVnJKedHeD0oqOijAxpJyZfQA5COXaZ1IlPZ+nlpgS9GsBPByX9nM5BP8t8rwgRkvju D9zQ== X-Gm-Message-State: AA6/9RlYjXfm+AD8urq6uGIgKhk/eDAb6/MaXZHQH3p8qgJ0gxJBLUcbKqsVpTyuhv6scw== X-Received: by 10.194.44.69 with SMTP id c5mr4840023wjm.80.1474717766180; Sat, 24 Sep 2016 04:49:26 -0700 (PDT) Received: from android-c07b90b023759a5a.default ([95.148.161.240]) by smtp.gmail.com with ESMTPSA id xy4sm11847455wjc.2.2016.09.24.04.49.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Sep 2016 04:49:25 -0700 (PDT) User-Agent: K-9 Mail for Android In-Reply-To: References: <9F330826-CF44-4584-961B-727EEDD9482A@cschneid.com> <50921841-5F6D-4EB6-9E94-8D32FA05C86F@koalephant.com> <69f23a7d-3fda-3390-d5e3-a9101b8c7045@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Date: Sat, 24 Sep 2016 12:49:23 +0100 To: "internals@lists.php.net" Message-ID: <3D8739E3-0FB9-4757-B324-BE434750903C@gmail.com> Subject: Re: [PHP-DEV] RFC: Strict comparisons From: rowan.collins@gmail.com (Rowan Collins) On 23 September 2016 23:14:37 BST, Dan Ackroyd wrote: >On 23 September 2016 at 17:40, Rowan Collins >wrote: >> >> I've been pondering an idea for ages of a generalised syntax for >switch to >> specify an operator to use, so you'd do something like this: > >That's technically possible already: > >function foobar($foo) >{ > switch (true) { > case $foo === '1': Yeah, switch(true) has always felt like an ugly hack to me. If I ever do write up my idea I'll cover this in the RFC, but the main problem is that you have to repeat the "$foo ===" part in every case, which means a reader can't assume all the cases are of the same form, and in many situations you're better off just using elseifs. A switch(true) makes more sense if you have a bunch of basically unrelated conditions with the same outcome, at which point a bunch of case labels is possibly easier to maintain than a big chain of boolean ors. Regards, -- Rowan Collins [IMSoP]