Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107593 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34626 invoked from network); 21 Oct 2019 03:30:32 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by 76.75.200.58 with SMTP; 21 Oct 2019 03:30:32 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id ACF4A2C600F for ; Sun, 20 Oct 2019 18:14:05 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) (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 18:14:05 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id 4so3540475ybq.9 for ; Sun, 20 Oct 2019 18:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=L56lpSpEOf8vq9SmAiD1yHIFxyR6zOV28c0TOtptsYI=; b=RGAtxjZGY4trbuVL0ZgVRr35+HYwCHe3y6PzeUjIQad301P8EReIwwkWx+h7OU6i3k Qm8aBM9oxABybGxb5oyd5KNEm7VyTzIRVrujL4LUGemN6E+DTxmuC8njIt0FWVdYuk4h hswbZaglEFhNqVO3put/iTOIf5M2QEnerX3TB4KoEAE71FpPUIuUGiJKTiZO/WtccEwj iIKsXZ8AQLXpBl46iM6eXTiC7LxOLGEQFCZIazyClmu4FN4eo7b7/vLF8Qm9Hy/2yAKr yly4E0xagb5VblX8oH+I7zKuElZB3z7bR4c9q/1gG7QA3r2lg8LyhmsHsd5J1iYxgqcP KQuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=L56lpSpEOf8vq9SmAiD1yHIFxyR6zOV28c0TOtptsYI=; b=gO4/jLh7F5tt/1U2Uh4fcx6bca4934Yz1GUcBM8iO9lXm7sv+986RyfWwWbJiNzZBK cSeSF/3RbeM3U0VqUGjpzkVUhqkS/d2xruMMOuvH+SLBb1b5ktOG7cpQvWkzMZBbusyr dSMQKmF4O4f6toT6M26eGfJ7Z1kA43teR51ksm591aGYOOjFX8UB+XjVnO4Ue5CJHnd5 7QR8zAl88am70y6yaJW6o8buBD7dTmV0/9onxm1uoPhwndoN0PjIebQl1X7Cvzkecsxd wODPnHGv4QLrmxwnErGfOe84vb7aD1pWCQJo5y0BPzEvxbQ+Br107ALU6sezc6/R9zNu 7OFg== X-Gm-Message-State: APjAAAU2pvRbssIKNSRLi09rZWmj4XKqFqZRb+HTSokPHroRnibvmARi 0hEdusq4E9GX+jh6xZdKQ6w1dQ== X-Google-Smtp-Source: APXvYqzwS4xC72kq5ta524auCTOXeebGmVg7g1IVz5IoLWC44sL/HNq4HfXC8n726Actht61g3JM8g== X-Received: by 2002:a25:3086:: with SMTP id w128mr14570174ybw.385.1571620444492; Sun, 20 Oct 2019 18:14:04 -0700 (PDT) Received: from ?IPv6:2601:c0:c67f:e34e:b8c9:c7cb:696c:b956? ([2601:c0:c67f:e34e:b8c9:c7cb:696c:b956]) by smtp.gmail.com with ESMTPSA id 5sm3144694ywb.73.2019.10.20.18.14.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2019 18:14:02 -0700 (PDT) Message-ID: <9A432898-EB7A-45C9-9C6F-AE6392B9B5C3@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_14712301-679D-489B-8C31-862ECFF2DFF7" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Sun, 20 Oct 2019 21:14:01 -0400 In-Reply-To: Cc: PHP internals To: Kosit Supanyo References: <3D85D31D-5DDD-42AA-B465-6ADBE72D952A@newclarity.net> X-Mailer: Apple Mail (2.3445.104.11) X-Envelope-From: Subject: Re: [PHP-DEV] 'switch-expression' and the 'type guard' unary operator demo From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_14712301-679D-489B-8C31-862ECFF2DFF7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Oct 20, 2019, at 7:08 PM, Kosit Supanyo = wrote: >=20 > Yes because they are statements, that's the point which I've stated = many times. And I am suggesting that a block-enclose expression should not be = limited to expressions only, but instead be able to use statements in = the future. Using commas ensures we can never go that route. > And if your argument is that there's no place in PHP that uses commas = within curly braces, you're wrong. PHP already has one. >=20 > use X\Y\Z\{ > A, > B, > C, > }; You have a point.=20 But that use-case is not a block, it is an obscure short-hand syntax for = which nothing else in PHP is similar. I would not expect we should use = it as a model unless it were for a very similiar thing. > if you did do some researches Seriously?=20 > you might not think they are inconsistent at all. In fact I'd already = gave you some examples in previous reply (C#, Rust). I did not state it before because I did not want to spend time on things = I felt were irrelevant but the fact another language uses syntax does = not make it appropriate for PHP. What makes it appropriate for PHP is = "feel", consistency, and how sigils are already being used, and how they = might be used in the future. But I am not saying you do not look to other language for inspiration. = What I am saying is you cannot look to other languages for validation, = at least not in a vacuum.=20 > No one is limiting anything. ... If you think that anything inside = curly braces must be separated by semicolon, 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 =3D switch ($x) { case 1 =3D> $arr =3D get_array(), array_pop($arr), case -1 =3D> $arr =3D get_array(), array_unshift($arr), default =3D> null, }; What if in the future PHP implements variadic syntax for assigning to = arrays, e.g. $var =3D 1,2,3 where $var could satisfy a $variadic = parameter set of parameters w/o requiring `...`? If PHP embraces that = =E2=80=94 note GoLang has something similar =E2=80=94 then will comma = syntax allow for it with hacky use of parentheses? $y =3D switch ($x) { case 1 =3D> $var =3D 1,2,3, $var[1], case -1 =3D> $var =3D 9,8,7, $var[1], default =3D> null, }; > That's because `throw` do different thing at the engine level not just = jumping things like `break`, `continue` or `goto`. Are you saying it is literally impossible given the current engine, or = just that it has not been done with `break`, `continue` or `goto`? > If `break` is allowed in switch-expressions and its behavior is to = break outer loop, don't you think it could be an another inconsistency = or confusion? Because I'm 100% sure when people see `break` within = `switch` they'll all think it should break `switch` not something else. No. I would assume the other, so I have to assume I would not be the = only one. > you are the one that limit yourself. 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? -MIke P.S. And I do not mean my input is needed for PHP to be the best it can = be but only that having different opinions debated in a reasoned manner = tends to make for a better outcome. --Apple-Mail=_14712301-679D-489B-8C31-862ECFF2DFF7--