Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107566 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57425 invoked from network); 17 Oct 2019 11:21:23 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 17 Oct 2019 11:21:23 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 92E712D165F for ; Thu, 17 Oct 2019 02:06:00 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 17 Oct 2019 02:06:00 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id l12so1295650ilq.4 for ; Thu, 17 Oct 2019 02:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=g6qvV3B4m5T+ksN8txqWGRubjkPm+2FqF8SGG5RI/OE=; b=AzanDz9JyeduNooQjc3ryKLonuJjdJR6tnfGuZKCQq2JNQ3UpUPS2tXGbizEVHsNF6 Y8f1rEllvvawCC1vknhoSRdjCKauh7F86FeoSkM/jyfPegRj8XjdHdDVScNMjEBx/hNc KJ7NBRPjbWDoU5AGsnEb/Z8awgpUFBwluaVxo34CSFBKqObNFsVNfqyyppSHw2ZIqsV6 0KR1wiZHt8do65mGxJwB7QQAZ552j6/STwA80cZzso+NZCZC+QcTdb9zW02zAqkd+YEX gz9MIghXaNmTqULlyVOsVnqgPVxwKQ6qvzSy6hJtgJrtyCNlU2742B5gwBAuRXHey/CW 2MWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=g6qvV3B4m5T+ksN8txqWGRubjkPm+2FqF8SGG5RI/OE=; b=k7y9DxXeAzl8WqFHYFBNxhmEYveQ84K7nIm17fT4FuMB9ExdK0rYKcP2Abm17caRv0 dgTHTzzeXG5vIwtwO4JCy98VO4sHxSoElpuVpl2U4kfFCWDfZxePkuy+k2lk6VRTgs+E 07O34jrE4x8O3WkBTsHK0UQ7kfJN4gSgbHjFiHgGc5D+rD+S6J96K+gYl7+jwNljU6yZ hU5GAdjid8MMRDaKRGVvF+OkaEtHtZoskSPGAec16mO3hx//yUs8vFGlHueYUZk6KgSd pOgdI88suv1eE8Ys4jBxDFC/leqcP5vN3VL3NGro89qrSogt80eh86ETVSUEFjy9zpaE ASEA== X-Gm-Message-State: APjAAAWnRVC7P5B0qNTsGiM1CDXpl2vyW7W5P1WKUbekVwoaRvywY2Ft SbqWAHGfw3Qu391DkmYM171KpBNekeoFFTy/CsoN3w== X-Google-Smtp-Source: APXvYqyxonQ+UnCpKWTYUZHiOWjlyG7mg1WNIZzAjTpgVL0xvwr/ycF54F69RcXIW2+3S0g1hNdJlIVEuCQ/gxW0XX4= X-Received: by 2002:a92:4144:: with SMTP id o65mr2608137ila.206.1571303159429; Thu, 17 Oct 2019 02:05:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 17 Oct 2019 10:05:48 +0100 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="000000000000a6fed305951786a4" X-Envelope-From: Subject: Re: [PHP-DEV] Inline switch as alternative to nested inline conditional From: rowan.collins@gmail.com (Rowan Tommins) --000000000000a6fed305951786a4 Content-Type: text/plain; charset="UTF-8" On Wed, 16 Oct 2019 at 18:10, Bob Weinand wrote: > what's the concrete advantage of this syntax as opposed to the already > possible: > > $value = [ > A1 => A2, > B1 => B2, > ][expr()] ?? C; > What's the concrete advantage of switch over if-elseif? What's the concrete advantage of if blocks over conditional jumps? The primary answer in all three cases is surely "expressiveness". If I came upon code like that, it would take me a while to understand its intent - does $value end up as an array, or something else? what's the ?? there for, and when will expression C be used? Now, it may be that the task in question isn't common enough to deserve its own syntax, or you may not like the proposed syntax, but I think that's very different from coming up with lots of clever ways of writing something, and requiring new syntax to have a "concrete advantage" over each one. Regards, -- Rowan Tommins [IMSoP] --000000000000a6fed305951786a4--