Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109556 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17167 invoked from network); 7 Apr 2020 17:30:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Apr 2020 17:30:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A4314180503 for ; Tue, 7 Apr 2020 08:58:53 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,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: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 7 Apr 2020 08:58:53 -0700 (PDT) Received: by mail-ot1-f47.google.com with SMTP id v2so3655271oto.2 for ; Tue, 07 Apr 2020 08:58:53 -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=ak08ZH64XxJOnDMEAgmGQUTVLwatjT875YiQ/RGvvzI=; b=agiZU8RO0kQ5T2fpm88JVt9xfgbQ4AuOfDF0IaPLlnkM6G0HrxRMHTunNGI8yF5dDx 5x95gcAavB+kDOhFx3ujAE2q9+L3SSZ8GCw1ajDwFrr+kOvJKQ+hge55qBR8oFemkflz xX143W2SiU9wSxbjFoRdtQogLq0CyYc7OZqu+ODTA/dX2RgL9wP5aNuF1/XQd+vjNYDB UIT9tDiztQ4gB7zixSbLzqNYd5O3oAMvfNbMLNxcnFBnBtgyI+M1VRLaiYlUyG+OWzhK FOh2TeiI68Zg57eHY7Hd2tWoXJFi2lJYS3s6gI84yn6X3DKnev9OfWfwdDDupbwDXE9z ElQQ== 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=ak08ZH64XxJOnDMEAgmGQUTVLwatjT875YiQ/RGvvzI=; b=El75LOsRVPYRYPMNi1wRjT52jjMiLpMUkbb0UHJsiC07RNF7d6yTGBz3tQpyFC0FZM 95DgpKuvMj4LUE+1iL9nH2OLxSdRyz9CS656lZ027/98owRaBI0ZOjmsazRoCdU6OGRp G1nvc9LlowkNQzvL/yDN4qcbiBcaoHCCF2FrGM+Q0yKh+R4nAk3NzUa8ijIRYQPa6CUp udUqYuUnCTY4U2Uvnrv3yj9HhR2q1Z7119Dqh3w2VI1Bs8aW1XJacMd86N9xmwq528Cq bWmxjAAghilxTg8iCNqd6sG7jPMI80ZCTqklHh9cUeN2CLkl1IF+M2ZFDtMpbYhvGQSP wl7g== X-Gm-Message-State: AGi0Pua7H59dgAsw7LXoEZY5mUF+INkUVQOc1CcRM1UvMPPM1jlnZWI6 wIwrAZiDF9iRBmbXU2as1fQlID86Y3tDQPldeV4= X-Google-Smtp-Source: APiQypL+aUL1tXgtcqWG31zdgCs8rLUXESDzb9br3cDfLp+TCUcVt1ui3jABeGazj4VGJ7jW8SVhZpQP0RaWwF3oKa4= X-Received: by 2002:a9d:ef6:: with SMTP id 109mr2027100otj.43.1586275128754; Tue, 07 Apr 2020 08:58:48 -0700 (PDT) MIME-Version: 1.0 References: <59e48d22-6d2d-19df-1b4a-cb2e7281ceea@web.de> <400d7cec-527b-1bae-4939-17c936b0c018@web.de> In-Reply-To: Date: Tue, 7 Apr 2020 17:58:36 +0200 Message-ID: To: Enno Woortmann Cc: PHP Internals List Content-Type: multipart/alternative; boundary="00000000000090c69d05a2b57530" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Type casting in array destructuring expressions From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --00000000000090c69d05a2b57530 Content-Type: text/plain; charset="UTF-8" > > 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. > My personal pov is that the use case you describe is not sound enough to require a new syntax; this is still fine and explicit (borrowing from one of your examples), especially considering the weak points noted by Rowan: $now = (int) $a[0]; $future = (int) $a[1]; The huge benefit of Levi's proposal is that it works with any types, not just the castable ones: any class/interface would fit there. This means this new syntax would provide another "type barrier" that could help the engine or any type analyzer get a better understanding of the variables at hand. > 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? > I would abstain from trying to answer then. I now understand you had this different use case in mind, so I would totally understand that in turn, you'd be not interested in working towards Levi's proposal. On the other hand, I would so much like you'd be :) Cheers, Nicolas --00000000000090c69d05a2b57530--