Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110459 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77136 invoked from network); 10 Jun 2020 07:06:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Jun 2020 07:06:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F00781804F3 for ; Tue, 9 Jun 2020 22:50:26 -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=-0.7 required=5.0 tests=BAYES_05,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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) (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, 9 Jun 2020 22:50:26 -0700 (PDT) Received: by mail-io1-f44.google.com with SMTP id c8so828432iob.6 for ; Tue, 09 Jun 2020 22:50:26 -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=H+Kd2vc+a5PegQ8E0ixcM5EgKfmmdqThEt3ki20NMw0=; b=tZBxAGKNmbjnAdKVcfjeA257qalHarca0UG4sbCm5IAwC9LA+6iE51cvFCYvP39Z8l EnK7daGPv/jLev1ZW+oQuz6H7chqE/GUFEwjQDbZ43PMkTktAyUs+B5/BpxjNIsEGOZm vvuAs/IMiEwvHhTYbEJk5TMn7ZzzvG0iNl0lSD+rqRCs7jVTK7WHtku4J+njeWg6XKoi 2sYSAGiigFt52XsXOw1z5h60g3eFUmPa7BDIdoFSYPur5xpIozSUfQlxbI0KLXetQNUD QtI8lfVVrBfMiAAAZPwqX5BfhQYUvjxJblClPC3IJh3GkoZY4eMiuoEExl2LHicSt/VW feiA== 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=H+Kd2vc+a5PegQ8E0ixcM5EgKfmmdqThEt3ki20NMw0=; b=Da7wsTAN00sCTCO6P8ki3R9CbuGSeQtHlh5/nMUf08gaqsScSa5QtGySJer0wvj+3Q sct6GF7O5ELmSZwUSl+EXi9b2VWuZUVhhvjHD229VksvaEkgu2aavnFyynNmmw3Qo4G9 PeqghLlCoyqfEpEaMZ77BjfOhOWSWqBEX2jHXIXx7DmaTREv8P/XgAPM9xkJDjkq6KLn KUWnpn/4QUeTI2h4LYIkh7A+xQzFax+k87DvtOK+Txl7BkQfuY/F0JgddnNgmKHdr3ks KsAbQTJxsUxuIdenpH9E9DCuwUL6iBe+xgtvarf6792hGfGJwpP7FWp2SslE6AyKnlrz VdLg== X-Gm-Message-State: AOAM530QCGELy5/8wwfGPTeZz9pVz47F7KJ3L+qfWOA2PTqD90qedOn8 O73BAp5siENLxoOPCAKawJtQBzmUFcKflE6bg2U= X-Google-Smtp-Source: ABdhPJzdQKjuxxW1V1ldw41EHOodYvE9Acs5Bi/T4a6KkDCXyMfpgFYB1ph5FRrsrutRM9ASV7tE93DEB/boUfgQdNs= X-Received: by 2002:a05:6602:2e87:: with SMTP id m7mr1699986iow.203.1591768225886; Tue, 09 Jun 2020 22:50:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 10 Jun 2020 08:50:04 +0300 Message-ID: To: Theodore Brown Cc: Benjamin Eberlei , Sara Golemon , "carusogabriel34@gmail.com" , internals Content-Type: multipart/alternative; boundary="000000000000ab6faa05a7b46b1c" Subject: Re: [PHP-DEV] [RFC] Shorter attribute syntax From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000ab6faa05a7b46b1c Content-Type: text/plain; charset="UTF-8" On Tue, Jun 9, 2020 at 6:57 PM Theodore Brown wrote: > Hi Benjamin, > > On Tue, June 9, 2020 at 6:55 AM Benjamin Eberlei wrote: > > > Larry's suggestion about `#[Attr]` makes an important argument about > > allowing to declare attributes in code in PHP 7 in a forward compatible > > way that has not been brought up before. > > > > ```php > > /** @ORM\Entity */ > > #[ORM\Entity] > > class User {} > > ``` > > > > This code would work on PHP 7 and 8. > > That's an interesting argument. After thinking about it more, though, > I'm not sure I understand what the benefit would be. The docblock > annotation needed for PHP 7 is *already* forward compatible with PHP 8. > So wouldn't this just be duplicating the attribute and opening the > possibility for them to be out of sync for no benefit? > > Rather than duplicating attributes, wouldn't libraries simply stick > with docblock annotations until they need to depend on other PHP 8 > features anyway (e.g. union types), and then switch completely to the > native attribute syntax? > > Furthermore, even if there was some benefit to having an attribute in > both docblock and native syntaxes, it seems like this is a very short > term concern. In a few years once libraries are depending on other > PHP 8 features, will this even matter anymore? So I'm really not > convinced that this forward compatibility argument should influence > the syntax choice. > > > The `#[]` syntax would have about equally low breaking potential as `@@`. > > Is this really the case? There's no benefit to adding extra suppression > operators, but I have seen code in the wild using hash comments starting > with an opening bracket (e.g. to comment out an array, or for making > checkboxes like `#[x] Some comment here`). > > > As such, instead of going through each alternative syntax one by one, > > with with each having a 2/3 requirement to overthrow the old one, > > I would be open to restart the secondary vote on Attributes syntax > > with `<<>>` (status quo), `@@` and `#[]` using the same ranked voting > > algorithm that was used for the PHP 8 RM vote. > > I'm certainly open to holding a three-way ranked choice vote like > this, if others are okay with it. > > > I would take on the work to write about the third syntax alternative > > then. The VoteRFC could just link to the three individual RFCs where > > each discusses their syntax. > > I added a section to the Shorter Attribute Syntax RFC discussing the > pros and cons of the `#[]` syntax. Let me know if you feel it isn't > worded fairly. I think it would be preferable to have the syntax > choices and voting options presented in one document rather than > spread out in different places if possible. > > Best regards, > Theodore > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Hey, How about #@Attribute as a middle ground between #[Attribute] and @@Attribute Shorter as there is no end token and maybe directly compatible with old style docblock doctrine annotations. It's true that the advantage of compatibility fades away for the #-starting attributes when you think about having it inline as it would consider the rest of the line as a comment but I still think it should be evaluated, considering the current options. Alex --000000000000ab6faa05a7b46b1c--