Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109759 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55179 invoked from network); 21 Apr 2020 18:49:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Apr 2020 18:49:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 056641804C7 for ; Tue, 21 Apr 2020 10:20:30 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.web.de (mout.web.de [212.227.17.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 21 Apr 2020 10:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1587489627; bh=1sZ82ZAsFPPKwrnyq/WZJvlJMwTvKzi1TEahf0pkH4U=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=X7WDuidqASKwgpc/Q9gtDe8VSZmyBwRUZwzgLzPUpdOj9UkMSKwEbDCmhfwj1HU3v y7Dw4I2NdNoAreRSg9HHAShHy9NpOKdgTERsG7oYcNGck4zAAxuNzO79LrpWIO7CEJ +0QP51R5ejVNv0ZCdKvzPhJ+RDFOdQ+hJC7PHCC0= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.178.36] ([37.138.91.140]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MDP6H-1jRkJy1UBZ-00Gqf7 for ; Tue, 21 Apr 2020 19:20:27 +0200 To: internals@lists.php.net References: <2b8e5da5-2f21-57a2-7e7d-243c686cc69d@web.de> Message-ID: <725377f8-f8f2-a681-ee8d-c6124d7f523f@web.de> Date: Tue, 21 Apr 2020 19:20:27 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Antivirus: Avast (VPS 200420-0, 20.04.2020), Outbound message X-Antivirus-Status: Clean X-Provags-ID: V03:K1:g1k0zie58mZvwx9C40WsyTGCnP6GYV1YorzghXFT5YpAJBx03kM eg9fDoVwWVUAXhnbR+JbxlUXViz9kOI3OOvYlFWzg0fqH3sso8KT3Oqm5WNRixFYVfRBq4S 49m8+s8z381hAhjo8D2+79ahof3D9tfpr3FPIuhIUZjWqKUq3s6uEZhVq7LnEJ27lVHTCyw sDILfaRK8qTRn16STooOA== X-UI-Out-Filterresults: notjunk:1;V03:K0:33wSkBqp2Bo=:q1HZrXA9HJOhflIObNSTko q3HXE8QO249LsjPvGQFUIy4C8rXA3yppu/UtWonK5xXU5aks/U38V0qiSN+bL16vRsCbY0mgP PLg5adjuD6yOjdJ68hFglnY2KqMnWOaQUBkziBRqYsJhv5eJwW9CDvGFhAmUnFzX7VSkdRXdJ v8DZU5doFxv6hMrwE/tN+XJdb2MA4YWp9s/mQaTQZCNDIPl5u6aKivAkS8tML0H9D4X+755cX LkdBG7H7OtKyLj1W6xRp7D+vSPXMYvBsUsicHyRLCiJBfuYYkUn99YlDByf4BTMJNpoFxLSPJ L7iU6mQEP/T1mvwDVQpqaUzqBisVtIJLyT1O8WRdOoJpNERnYcGzeehN06mzWHV465Y0a/9HF 81+9RPrMXMYyP0/M5OZtLiTyTEvJZA2320MooHaA+SZsZLfsWE7l3DI57HVEJInt0Bn+pWhja JkTqen1NZNsVMNNl3DxtxBCeg+bcD98fBoVlZDe6ub3SyZiBkriplPESeO99pPKeAU1k+63c3 +ZnCrN2rB/PtrFpIa8Pw2QzoxSoedr1R/MEx3savOm7RlOh42VV647ddv79oT/jxW/JKxm6ez 4Bmdh9b/TcfIe9jscAI9PK7dJCZy9pRyYAsrW2HZEBelWCYCiJZjQ6TfR28vdHykRpzW4iO2K CCICxv62H8PWcUkEY7XyzXbAoZtdrAlae03ua/2ay9S80y4ZjPwn0o1h670Gioz7zyrCADVxb KCVlBZadednrQe56ExXBEgNQKYwmtT2qG6uFZj1sv8Q1yJzx+Gdw2bQG/kpCiSZsGf7HH7H6/ lOXJ5EWz24KZgw7m/wCKRQCvdsHBnPg5i7QUEy6EyWU6iZPpXaHvTfM8pUGG2UmnCjCaWtQku OtVmdqa0ixft2PPqh6050kSeoPqp1eUZmPdFnal92/gai9SfKLyEYt0ZBNbxGhEYewSTBrhBI tnZV0ldeHY8OTqKaMzO+UpYlmig6AL/AkQaARmSNfBUInLOVLstcwLbo82TzoLA3xNc54bGy2 lWcorLxrRZECAHo++qqYDLiw50Oj92y/oDsAXyKzLQVRomKxD1qbV1plszA0K+hZ7j0ZXqPKF 7S90ewdH+rRtHj3qizbYDM88iLf4VXWXpTjUxk4B+sVimFbWY/eruTnQFXxYNPEVjt1F6JGB0 RMg92HANjFFB35BJs/qjquou/bwsXWzvGf/eZ73g4MmKtQ721dDKOhcUDVbFroVjp0IXR+90i PS2UuCK9gfDBK6MCJ Subject: Re: [PHP-DEV] Type hints in array destructuring expressions From: enno.woortmann@web.de (Enno Woortmann) Am 16.04.2020 um 16:50 schrieb Nikita Popov: > As you say, this syntax will likely run into parsing issues. Once you ta= ke > into account that types aren't just "int", but also "Foo|Bar", and also > consider that we have support for references in unpacking, you could be > left with something like > > [int|float &$foo] =3D $bar; > > Without actually testing, I would expect that this is going to run into > issues of similar difficulty as the arrow function proposal encountered. > > Rather than integrating this into the destructuring assignment syntax, I > think it would be more helpful to view this as the infallible variant of > pattern matching, which is also being discussed in the "match expression= " > thread. As suggested there, the syntax could be something like > > let [int|float $foo] =3D $bar; > > and would throw if the RHS does not satisfy the pattern on the LHS (unli= ke > the match variant, which is fallible). > > I think this might help to bring things under one umbrella, and to draw = a > clearer line between this functionality and typed variables (if it's jus= t a > pattern guard, then it's expected that the type restriction is checked > instantaneous, not enforced persistently.) > > Nikita Hi Nikita, thanks for your response and your assessment concerning the parser change. I've played a bit around with the idea and came to the conclusion that changes like these are far beyond my knowledge of the code base and my C skills. Consequently I will not continue working on this idea as it moves away from my initial idea to simply cast values. If anyone wants to take this RFC draft, feel free to tackle this topic further. The secondary voting of the "casting in array destructuring expressions RFC" which will be closed in two days shows some interest into this topic. Cheers, Enno