Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111485 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 86609 invoked from network); 12 Aug 2020 10:09:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Aug 2020 10:09:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5B1231804AC for ; Wed, 12 Aug 2020 02:08:46 -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_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 ; Wed, 12 Aug 2020 02:08:45 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id b30so748928lfj.12 for ; Wed, 12 Aug 2020 02:08:45 -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=IF1mkX1KN3NZpRKqM9esIsx+uHJ53EiICQmX97xM6bg=; b=C6LfvMrYHaqm+eADwGVV8aoCH/nKX24C0oGVrP4mEMmrzN7Hpa5YculLSrO/ZnFxni Q4oGzJbnFvyvc/qYvsKCJv3WGRuh0UW+vzp9baHIaHR0HWlByYPJodvFmGe7Wlnifg8I lGqusxRlqWxZEZ882rJs46TXgSmVvx8XqvpXoiGk8D8F1KAZiZlcvpLkNSQOsC4EjGAW zF3n5+Mt4Gy4gEbngPsHLtmSMlMgnH/Ifwlge/ct2Njccz3++slI/UmtWPe86KoBuRCs ibehjKpa8iusEzmTRM4xdNXvZ4lXg6jelHtXo9OYNvWN5vgnav+b5zfbvMW7eUtqjD8S oX4Q== 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=IF1mkX1KN3NZpRKqM9esIsx+uHJ53EiICQmX97xM6bg=; b=Hi2Nyf+/DfecARMHF6czZlxZIiOywFlIxSEZ23nwEBunDikvi6E6/wUP3iucakELWp 0E/6ZDDiWcqoej0cq5ZoRP6lInQzNAXZ0745W1/aeR8R6FWHsGm5Cnzs5tRUgl23xU6o ioF4uzU1F9dLXXYhHVZnw1cXxp0EfwNBmDPHN610qFbfOnjmoSk3NDW7+7wxYcGOqCiA EQyVkv4YaV0AODhQlKCcefx22KkmJYDZjNarRvGx3hip6YYgPr/7VsSkhgyCtLpMfz9S s1txTOIEcMpBVhn449I6Tf6wLKoM05poNSBIJUYBHMfFMdxTp1EfLuusmP+GhYjBZfAl h/Vw== X-Gm-Message-State: AOAM533awKdc0lNj0mIbrQkzS7TzQ6XK1kTclIE7VMrpYQfdtCwhsIg8 Y88t7ggd8XgwxqO/fjNvm68F2gz3unh06remHW0= X-Google-Smtp-Source: ABdhPJxHbzlqLfklIPUlimL6Ey08Rn54W7/HD4CfSj/JQjwu7TlJ829Zp/FV8yNfTxijEDt6chTa5W13I6ipOidzyPU= X-Received: by 2002:ac2:4c33:: with SMTP id u19mr5300027lfq.154.1597223322288; Wed, 12 Aug 2020 02:08:42 -0700 (PDT) MIME-Version: 1.0 References: <59019606-a3fd-3c19-e962-a847689244a9@gmx.net> In-Reply-To: <59019606-a3fd-3c19-e962-a847689244a9@gmx.net> Date: Wed, 12 Aug 2020 11:08:26 +0200 Message-ID: To: Andreas Leathley Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000c084fa05acaa88a9" Subject: Re: [PHP-DEV] [VOTE] Shorter Attribute Syntax Change From: nikita.ppv@gmail.com (Nikita Popov) --000000000000c084fa05acaa88a9 Content-Type: text/plain; charset="UTF-8" On Tue, Aug 11, 2020 at 6:26 PM Andreas Leathley wrote: > On 11.08.20 18:07, Sara Golemon wrote: > > Writing this on PHP 7 (or any earlier version for that matter) would be > > valid syntax (ignored as a comment): > > > > #[SomeAttr(123)] > > function someFunc() {} > > > > That's what's meant by Forward Compatibility. Library/Framework authors > > could aggressively adopt attributes with the #[...] syntax, they can NOT > do > > so with any other syntax. > > This would be a feature if libraries start parsing PHP token by token > and start supporting the #[] syntax for the 7.x versions of PHP - then > early adoption would be possible and it would be a real feature. But it > seems unclear if that will happen, as it will probably have a heavy > price on performance (and might have some complexity). And if some > libraries implement it but others don't, then it might get confusing for > users about why the new attribute syntax sometimes works and sometimes > silently does nothing. > > It is also not perfect as multi-line attributes with #[ still break, or > code with #[] followed by more code instead of a newline and then more > code. > To clarify the forward compatibility argument: As far as I understood, it's not really about the end user, it's about the library implementing the attribute. The library providing the Route attribute can write: #[Attribute] class Route { // ... } and make the Route attribute available both for use with PHP 8 attributes and PHP 7 docblock annotations. With non-FC syntax choices this possibility does not exist, and the library will be required to provide different class hierarchies for docblock attributes and PHP 8 attributes. The ability to write #[Route] for the user of that library is an additional possibility on top of that, but one that is technically more involved. I think the primary forward compatibility value lies in the above usage. I believe this was explained in some of the earlier discussions, but I wanted to repeat it in this thread, as there seems to be some confusion on this point. Regards, Nikita --000000000000c084fa05acaa88a9--