Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111615 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94497 invoked from network); 18 Aug 2020 21:06:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Aug 2020 21:06:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 152FF1804AC for ; Tue, 18 Aug 2020 13:08:09 -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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (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, 18 Aug 2020 13:08:08 -0700 (PDT) Received: by mail-qt1-f175.google.com with SMTP id 6so16152951qtt.0 for ; Tue, 18 Aug 2020 13:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=SlxsozUcYO28B/1oiOZsPoVeYRLNUE+kZtn2lsHjII0=; b=N15d+ebuhsOgwuAAJ7nv6NYq39IMZHhcNxxNZwdJcn1kELHJG7QLwaZhBhoIqGYRsL LVqMH+7GpqSIX07Hhor5nvHCAx5X82lYuRYJv4j+CcZmu99n1SZDbAqpSBjhRtp2ilm7 z52iK28bfUNxFKWUVi7wITzo0mZRzUlegyZ53pqop0RFR3YoNRRAyxz29hHu1zKjJ05S ecSGAYpto1Av57d5aX0NIDiZfKLN1mPUDOQufirPWYc1yqapfFkia99qoMgm9Elpot5t WMJzOLVTSqbjSBnWuw/JradoIudEVMP/whP0q1ESBad51nX9R/+V9w90IFu9yMxBS3Cg pnCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=SlxsozUcYO28B/1oiOZsPoVeYRLNUE+kZtn2lsHjII0=; b=h4ZzIYGEgqUpm/6NYh7CArG37hT+3n1mmvffLoWuymWdrVXeoI58wQbdJUgeJ+uZz0 7mO6CW9VIDUVzMoi6LYERZ3DS8d74CDYG2JOt6/ZU2l6OeULtjgnczgzJ78+qy8SzV3I 9JHYEDEHK7AYMuSM2RyOG/0/Lx8/PAGvSsxEAz1zpEm+JvCbFyFqTfN8DhwEdnhtku5L vCNLcRtJfWbUrp/ffnIplf2D4l0aarejmBa2HmXeraK8Jb5KyBgL1QnUClMWbEckJhZ3 G1IXzidgPy3HloilXEhnWixwTYH3JfmdtQSg5gnPlTlPETeHuNgOvFKkZzt/E0ZYYa3q SURw== X-Gm-Message-State: AOAM532rV8oEPT+pdrSZ+/7ZRknxfkhoZD1rhIM+lili2ykGFa7VjYQJ gqu+PkSq3Pp6AENCTYFRHTE/pmc8j8Ee0faT X-Google-Smtp-Source: ABdhPJyS/bGVN6G9dSfMtLVUQdJJc6hkZXAmShjP/7mkP4vvYxE4nV8VlZuBVcBkKbEUdQL+lXzDYg== X-Received: by 2002:ac8:1494:: with SMTP id l20mr20054763qtj.23.1597781286858; Tue, 18 Aug 2020 13:08:06 -0700 (PDT) Received: from ?IPv6:2601:c0:c680:5cc0:402e:6286:d5d0:1f2e? ([2601:c0:c680:5cc0:402e:6286:d5d0:1f2e]) by smtp.gmail.com with ESMTPSA id t1sm21951174qkt.119.2020.08.18.13.08.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 13:08:05 -0700 (PDT) Message-ID: <3303DAF3-B31D-434F-905B-49D221111F9E@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_DA645E92-069D-405F-8840-09AC5044FA4F" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Date: Tue, 18 Aug 2020 16:08:04 -0400 In-Reply-To: Cc: PHP Internals To: Benjamin Eberlei References: <5cc837df-ab47-628a-d29b-46d7933be973@gmx.net> <3A7CECC3-CDEE-4852-BF4B-4EC7CA1BD538@pmjones.io> <7d6c42a4-53cd-5e38-4ffc-02fe490d66a3@gmx.net> <9A07334F-1A55-4E7D-88B5-7E6BABFB5E81@newclarity.net> X-Mailer: Apple Mail (2.3608.120.23.2.1) Subject: Re: [PHP-DEV] [VOTE] Shorter Attribute Syntax Change From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_DA645E92-069D-405F-8840-09AC5044FA4F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Aug 18, 2020, at 6:54 AM, Benjamin Eberlei = wrote: >=20 > On Tue, Aug 18, 2020 at 12:36 AM Mike Schinkel > wrote: > I have been following all the lengthy discussions on this topic hoping = the list would come to consensus. And I had been hoping someone would = call the following question but since no one else has here goes. >=20 > The concept of adding attributes to PHP seemed to sail to acceptance = but, if you count the original RFC there have been three (3) different = RFCs each with the goal of setting or changing the decided syntax alone. >=20 > For every syntax proposed there seems to be a contingent of people who = are deeply troubled by it. Given that once a syntax lands in an official = release of PHP there are not take backs, moving forward with any syntax = where people are so divided seems like a really bad idea.=20 >=20 > If we care about future developers being happy enough with the = decisions made about PHP to continue choosing PHP that I would think it = would be incumbent upon us to find a syntax with a greater level of = buy-in. >=20 > Should we not: >=20 > 1. Postpone inclusion of attributes until PHP 8.1 to ensure that we = get a syntax that is reasonable acceptable to large segment of = stakeholders? >=20 > All the technically complex decisions are done, tested and decided. = The syntax question is still open, but not critical from a technical = implementation POV. All patches regardless of syntax are extremely = similar, just replacing symbols. The non-technical implications and = future related questions are what is up for decision. The arguments for = or against these categories are by now driving in circles. Postponing to = 8.1 does therefore not bring additional value. A decision has to be made = and we have enough time for that. >=20 > 2. Optionally have an RFC to ask people to vote on disputed = principles, such as "Are ending delimiters important and thus are they = required for any selected syntax?" >=20 > By voting for a syntax, these questions are answered implicitly. Then may I please be allowed to add another option (or two) to the RFC, = in hopes that it will be disliked less by everyone that the level of = dislike a set of people have for every option? I propose we utilize the "use" command but with required parenthesis = using examples from my code where I previously simulated attributes: // class attribute use use PostType('abc_product'), TemplateVariable('product'), VirtualReadonly('id'), VirtualReadonly('name'); // method attribute use use PrimaryKey(); An option to the above is we utilize the "use" command w/o required = parenthesis but w/attribute modifier, although this is not my = preference: // class attribute use use attribute PostType('abc_product'), TemplateVariable('product'), VirtualReadonly('id'), VirtualReadonly('name'); // method attribute use use attribute PrimaryKey; I have prepared a longer example as a Gist: https://gist.github.com/mikeschinkel/4c9cc5ed25d6e7665c0e9c70b3458fc8 = Appropriateness --------------------- The second option is similar to "use function " so while it is not = exactly the same, "use" is utilized by three contexts already, two (2) = of them w/o a modifier: 1.) providing a local name for a namespace, 2.) providing a local name for a function, and=20 3.) what is effectively an include() for a trait.=20 The semantics of "use" works for attributes =E2=80=94 i.e. "Use this = attribute for the following declaration" =E2=80=94 and having a 4th type = of use seems like it would fit nicely into the existing language. I would suggest viewing all the different syntaxes to see who "use = AttrFunc()" compares in terms of readability: https://gist.github.com/mikeschinkel/4c9cc5ed25d6e7665c0e9c70b3458fc8 = Benefits ----------- 1. Short; three (3) characters that =E2=80=94 importantly =E2=80=94 DO = NOT require use of the shift key (which my carpal tunnel would be = thankful for.).=20 1a. The 2nd options should be easy to type with an IDE/editor = that supports macros 1b. For example in PhpStorm you could assign ua to expand = to "use attribute " 2. Has a closing delimiter, the semi-colon. 3. Supports grouping, using commas just like other uses of the "use" = command. 4. Forward compatible in PHP 7 (I think.) 5. Uses existing T_USE attribute. 6. (I do not know if it would change the lexing of remaining tokens) 7. Does not prevent the nesting of attributes in the future as braces = could be used as they currently are with traits -Mike --Apple-Mail=_DA645E92-069D-405F-8840-09AC5044FA4F--