Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107596 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 46208 invoked from network); 21 Oct 2019 05:28:12 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by 76.75.200.58 with SMTP; 21 Oct 2019 05:28:12 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id E75512CF95D for ; Sun, 20 Oct 2019 20:11:46 -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=-0.6 required=5.0 tests=BAYES_05,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: No Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) (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 ; Sun, 20 Oct 2019 20:11:46 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id 89so9704292oth.13 for ; Sun, 20 Oct 2019 20:11:46 -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 :cc; bh=KKjtbColQZ8Qa2fWbIrlBFwQ+G1mkSSnpnlUoysJ8mA=; b=DFhpwcGrHuEbqwGtRS9V9CYUF/pLW8pDMjacHnj1SDvqHYDxitJoCIE5+nMKTXF9pT R3fFV4QxXxLGWxazm0/GayhCiYzjqXlg3ltgGh1saHI+PQpWvCR/IK0/5B+K1G3OEt8j gkHTxeLW14aSD+Yo3U7gxGzOU9jQNLZ6Utck6jx3zIetyVomCnAJ1GVtuLkpZw8swQTJ DPjuP5XKCMTg08too8cDpB9UxfXcMkDHfyiox6IrU7E7/9ip6vWF7gNEy0VomMbk6mod oYwHjGJkvhvrc7PwKkRjOf0ZD8DgaBVe4zWFCqjnvlRCknMavN43cIAbZgj5AwrRwiyZ Xong== 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:cc; bh=KKjtbColQZ8Qa2fWbIrlBFwQ+G1mkSSnpnlUoysJ8mA=; b=Ax0U7Fd90/4RJ/dVaV8iwmhXmNJsuY7PdqCxYJFzCgvdYtRgW1muKDdDYwc23DWIIl IrfjDtaeo6RNZif3qWSnGFE+n/8+olkTGeqrKMQkIkoFO/3QNEdVTwNiSO1s66PZHSgD CgM7kFXhiZXHRy5zNIXq4t2ujrR58/9vK9fY4XmbwBniHt+X5+t87vGTYuJ6IQodo5zG sDQrvCRCYXcdhKnZ1UZRTpqqMjvysRfs0e+l3Ep96FAlB/6BDrCvNytydAMB7Fx7fpmH pIDc3YDiK0tomPnbxtQbS39xNygDfyQnMjdFbUL48Nx45B0nlfKxAxC8rbXmUQL57fLG 399g== X-Gm-Message-State: APjAAAU/Y+/VDXzbv22r8CRmOn5NgMPWaEFkqo+PGpfy4NrT3fDM4guB jB972mYaMPzNH3LmdMYqcMdF2IPFXzP1mj1Dy08= X-Google-Smtp-Source: APXvYqyQBIuR5igk7+y6VUSO0x0fBMubQN7hmuU4tpE3oF5c7zIYi2JR+57ChXyLmtbaRinmAKqBsSW12LuTRPeVwOU= X-Received: by 2002:a9d:422:: with SMTP id 31mr6159731otc.107.1571627505739; Sun, 20 Oct 2019 20:11:45 -0700 (PDT) MIME-Version: 1.0 References: <3D85D31D-5DDD-42AA-B465-6ADBE72D952A@newclarity.net> <9A432898-EB7A-45C9-9C6F-AE6392B9B5C3@newclarity.net> In-Reply-To: <9A432898-EB7A-45C9-9C6F-AE6392B9B5C3@newclarity.net> Date: Mon, 21 Oct 2019 10:11:36 +0700 Message-ID: To: Mike Schinkel Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000032eebd0595630b0b" X-Envelope-From: Subject: Re: [PHP-DEV] 'switch-expression' and the 'type guard' unary operator demo From: webdevxp.com@gmail.com (Kosit Supanyo) --00000000000032eebd0595630b0b Content-Type: text/plain; charset="UTF-8" Hi Mike > Ok, so let's look at a scenario. Will we be able to do this in the future, > if we decide to allow multiple expressions to result in a final value? > $y = switch ($x) { > case 1 => $arr = get_array(), array_pop($arr), > case -1 => $arr = get_array(), array_unshift($arr), > default => null, > }; As I told you in previous reply, I'm working on block-expressions as well. So if PHP has block-expressions you can do the same this way: $y = switch ($x) { case 1 => eval { $arr = get_array(); give array_pop($arr); }, case -1 => eval { $arr = get_array(); give array_shift($arr); }, default => null, }; Which is obviously cleaner and more powerful. Are you saying it is literally impossible given the current engine, or just > that it has not been done with `break`, `continue` or `goto`? Yes, it is impossible to break out of an ongoing function call without exceptions. Your response makes me think you are responding in anger? I am not arguing > in anger myself, so I hope that I am not causing you to reply in anger? I > am merely asking posing technical challenges in hopes to ensure that PHP is > the best it can be. I assume we all want that? No, I was not angry. Just a little bit tired. I appologize making you feel that way. Regards --00000000000032eebd0595630b0b--