Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109554 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9426 invoked from network); 7 Apr 2020 16:42:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Apr 2020 16:42:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4EF0C1804CD for ; Tue, 7 Apr 2020 08:10:01 -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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, 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.15.14]) (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, 7 Apr 2020 08:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1586272198; bh=jWdvVUHnqtg5bj2eG15eOXt8WIUcy9IgHT8FP27q6PY=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=BRwL9N8Wpmgw+yK2Xk5dE3Xh9ToMkeGpl5BokFNHdZMs6suvJ5qsWOKzHMG47nt0l 18z954vBOd8rV1FOM8+SI3x3mGOULdozYw8mj/cuCD/X8kDQ8XNrIUs1IEifzDPyRz 0kfNDmb6euEUKiofKmVtJ+V9zGgKOvSYVWAuNjOw= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.178.21] ([88.66.220.134]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LmhQx-1inJzR1LoR-00aFrB for ; Tue, 07 Apr 2020 17:09:58 +0200 To: internals@lists.php.net References: <59e48d22-6d2d-19df-1b4a-cb2e7281ceea@web.de> <400d7cec-527b-1bae-4939-17c936b0c018@web.de> Message-ID: Date: Tue, 7 Apr 2020 17:09:57 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.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 200406-0, 06.04.2020), Outbound message X-Antivirus-Status: Clean X-Provags-ID: V03:K1:tfC+pXeFYiScUGojkkIClLmANrX5E1+1Sr+VYsp2WErgSoOd6Fy 3UICixve+W5sbfTwk55nv1FUg0XLRzMJOvEbGcUbA31od61IyMbbu/ms/yUjc6IYwhZN+DU cMkqiz1gci1T+yQZ67szo7KvEVSLl4qL3PmypWCaZjP3nGKpGfH2eyWStyttlQhtPe1wIyV UIrMa56O0DZ2zydGcw5SA== X-UI-Out-Filterresults: notjunk:1;V03:K0:OEIdsDz9S9U=:FR4Hn8odrcuF5G2QHUB0Nh kB7qSGiprQGPA01uX6lPy39xn5WrXej4csl53CLIO2faIeBccEr2zf8ySZDcnzRDJMVEeIVL5 WIV8KJqQAfwzDjrooAGFtwMkyXTN9Xn+6wLAMnKQ63UgE2omIoJgrN8sydH1QGFI0FJqfZXP6 08geed7oS48eaAVlCrAEE4fIeYXPX6bKzp+GIhT5dUtp+h5sp8QlCFIAq6dy2D0cA9Dw++q8f afsOLr3jeURhHG+ZVKTcXDLAw0YcmawlYNTnmdNXWcao5t5eJhs2momUITpDI85xzFymANoan efIhLjIlFLIgnDzhKWaTha2kBPMVMeypjpG2+IaviVfY+25UfqpVUj5R26K9xyjxKnxXjgjoN 9hLjJjkDmZSF7AOCbu4kYap2WCYt+s04qyjonLAlrXhVV+jZexIkDI0JXc7WfWGzNhgIpKIRg 79GqhtCfe+U/ZZZTIv+CryOxcoMTdoeG81AmjIhQvk0d1lMrdl013YUzZ5kbAo9Ao/KpjR23Q 2c9aZpwSOrCU+jF/bjgQXY9JqL2bChEbHEqjoY0hYLg3OC9VTRjw+7nE0mUke/polZ3UHPzAf K3VdGalpd5R68j/f04jmfhcrTf8ktP1uEif3hHTe/hG89ZGCTYAKpTiTuRZSursI8UPBvS1l4 1W4bomdJrkbs9QbP7cd5cERBbtTJfdnKSSfp//EpfpoCzdw65mx4m/dtHGzyhjjTOObuI2HKf 0naBuIYJ/bXb1vfu5juagaV3bJKGPPieHGwoMrirXakA7PTgocdA9AKxvfRRcm3mIoMG2kTB4 Ce50lPpFfdLyOyGBEH5obqdF6ocwmq/GwUhaLy2RhUmFve6N1eurpHSayQOrdRu42ITi2yTDZ B79v9miuzrdL99PFhMvXHEdmpGzqOv8HFIPtXaJfmbRgEY/syiOeDopRsX8Xf0ROeycH0MaUD p/eETkFM/1tTZTMFSroY2JZXhhtU1wde9z+aDd133xPM6RvMQuPFLgt/ecp26uZu0y4Nl3jP/ jmLb/wbi24BM1FhGyh73rZA+71gaxim7lgg5GAkKuJCE5bNM23/RSb6Z8j4wHqFLuaYEFB9Iq iLZ3bgyFJn17KrpBHmO5Yklcod+I8Qr1n9NXDdePZTne5yS7kfDleITlYgc+T0TrqWpOlyv7F aq585itQqJg03UvlnJmA36xOWvXYXlv+6xQvI5SbXkhMFwHnxJ4/wQYl3QPuXEZFMA83HZIts AL+AUwFv8UxlBaQ8n Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Type casting in array destructuring expressions From: enno.woortmann@web.de (Enno Woortmann) Am 07.04.2020 um 13:14 schrieb Nicolas Grekas: > Le mar. 7 avr. 2020 =C3=A0 12:07, Enno Woortmann = a > =C3=A9crit : > >> Am 25.03.2020 um 18:53 schrieb Enno Woortmann: >> >>> Hi, >>> >>> I've written the RFC and implemented a first patch concerning the idea >>> to allow type casting in array destructuring expressions. >>> >>> >>> The RFC is located at >>> https://wiki.php.net/rfc/typecast_array_desctructuring >>> >>> The patch can be found in MR 5296 located at >>> https://github.com/php/php-src/pull/5296 >>> >>> >>> Thanks for further feedback! >>> >>> Cheers, Enno >>> >> Hi together, >> >> As there has been no recent discussion concerning this RFC (tbh no >> discussion at all, I don't know if it's like "ok, cool idea, just let's >> do it" or more like "oh no, let's forget this asap") I'd like to start >> the voting tomorrow if there are no further comments on this proposal. >> > > On my side, I like the idea but the proposed syntax looks weird. > I would vastly prefer (and upvote) Levi's proposal: > > [int $a] =3D [123]; // note: no brackets, this is a type declaration, no= t a > casting operation > [string $a] =3D [123]; // TypeError or implicit cast depending on > declare(strict_types=3D1/0) in the file > > Nicolas Hi Nicolas, thanks for your comment. As the proposal explicitly aims at type casts when working with data from a untyped source (eg. iterating over a CSV file, XML without a XSD defining the types of the elements) an implementation following the type check proposal would force me to write my code into a file with=C2=A0 strict_types=3D0. As I'm a big fan of strict_types=3D1, I try to avoid such files (fingers crossed for the namespace scoped declares some day, but then I'd need to move my code to a separate namespace), also see my answer to Rowan @ https://externals.io/message/109305#109354 with different combinations. Maybe, as the type system get's a many improvements lately (eg. typed properties), it's also time to think about a refined type cast system for better control over the casting process (nullable casts already have been a topic, additionally strict casts as suggested by Rowan). I also like Levi's proposal but for the use cases which lead me to the idea for this proposal where I explicitly want to cast values and don't check their current types it's difficult to use. I think it serves different use cases. You mention the syntax looks weird to you. How would you design the syntax if you want to cast the values instead of type checking them? Cheers Enno