Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111365 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12643 invoked from network); 7 Aug 2020 09:34:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Aug 2020 09:34:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A507A1804D1 for ; Fri, 7 Aug 2020 01:32:30 -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-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 ; Fri, 7 Aug 2020 01:32:29 -0700 (PDT) Received: by mail-wr1-f51.google.com with SMTP id l2so885312wrc.7 for ; Fri, 07 Aug 2020 01:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=11R9z4K23RrTr9xyPWPfbQ+toJbCf++oVfCW++60LOQ=; b=Hmo/s3qqJm6LaayVxRJ/KL4yF0JNI7eRX8aVRofeI3wQPp4PKngGOibCpSsipQ0m2V 5lK9Q23TA2TIp8pgZMsSTfL2OWtczTKw8ibA3bSpQv4W3SJVk2Lo4EMOMBAHGRsfFRAT cAdKaLXMciC6dJS/bHWPVZMjJDjphCMKSpgVF7mbXXwv4jHq6We3jzxNOuD82dOPItIF orY9l9eWhL8o5nXPlAqrrxOHvj8S1QbRMoYBM+6HyIuaccq3UAAwlL9avWrBWbNvNMtv 1ie0tQveBMvtMcoyQZaN9POQeARTvS4j6ohqF/3VeTlU7Wkzth4j9bgQ/fl6PhrF2XEo 3bXg== 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=11R9z4K23RrTr9xyPWPfbQ+toJbCf++oVfCW++60LOQ=; b=eCwXc6lnp83psAxi26ddFJxZhalWjgW31CCp0MvV/ybR5DuegL8LrVy/Khva+bu63z iW6k5Z/MKcNsjro2FhcINxVGifg0wxBMPosSRPDorRrC8uUR3HJx64eEDiuSFVRHcSXS zeZx51kZmJfUAsyt84iMvpOKCUmCHJTuIGnnRBwN5D+E68dDr+ONHNhhjSssX9gGzdcY VfEOjOeq1s8j4/XWAhs6mDbHG3/n3TVPVEplc9x91bibEepgqc5NAQ2jAp5vAPQg6Fp1 gXkwamux4ZaihcylYlRJ6TuyB9cuhkT2P0mAPktfHP+iVn9/ncHCx0DrmzQaaz2b7zxB tBrQ== X-Gm-Message-State: AOAM530rt9J/lM3ktKYVbrl5kXNiYbuFQX+RnACyevrmiLWRyMSpMWOv K6+RML3BscqAnIF6yz12Tz3PAc+evpJBSp4YtC84pg== X-Google-Smtp-Source: ABdhPJwZQChPUTWrL8lddMfylXlcQCxjIkuS5yv8LBu0n+a4+ikOSvc8iEClxsw/XKWp0hu0JEMBH9I2QdngbMf2X5s= X-Received: by 2002:adf:edd0:: with SMTP id v16mr12013841wro.271.1596789147981; Fri, 07 Aug 2020 01:32:27 -0700 (PDT) MIME-Version: 1.0 References: <20200806091749.64675445@mcmic-probook.opensides.be> In-Reply-To: Date: Fri, 7 Aug 2020 10:32:15 +0200 Message-ID: To: Theodore Brown Cc: Benas IML , Rowan Tommins , PHP Internals List Content-Type: multipart/alternative; boundary="000000000000f2725605ac4571a1" Subject: Re: [PHP-DEV] [RFC] Shorter Attribute Syntax Change RFC 0.2 From: kontakt@beberlei.de (Benjamin Eberlei) --000000000000f2725605ac4571a1 Content-Type: text/plain; charset="UTF-8" On Fri, Aug 7, 2020 at 2:24 AM Theodore Brown wrote: > On Thu, Aug 6, 2020 at 12:30 PM Benas IML > wrote: > > > Hey Theodore, > > > > On Thu, Aug 6, 2020, 8:05 PM Theodore Brown > wrote: > > > > > While none of our syntax options are perfect, I believe @@ has the > > > best long-term tradeoffs because: > > > > > > - It doesn't break useful syntax > > > > Fair enough. > > > > > - It is equally or more concise than grouped attributes without > > > adding complexity to the parser/compiler > > > > Are we really going to debate that ~30 lines of code add complexity? > > Hi Benas, > > I don't know how many lines of code it will be, since an > implementation for it has never been finished. The patch currently > linked in the RFC does not implement it. > Curious what brings you to claim an implementation has never been finished when it was accepted by RFC vote? Grouping certainly has a finished implementation, Martin and I had it working for the original RFC, then when we removed it for the original vote had a working patch and PR as part of the Amendments RFC. I now ported the patch to the @[] syntax PR here: https://github.com/php/php-src/pull/5928/commits/c69e2de26c42c583a8ca0fa579c1be69d40bfc454 The zend_compile.c diff looks a bit complex, but it's really only 5 new lines for a new for loop over the groups and all existing code one level deeper. All in all the attribute grouping patch adds 26 new lines (and then tests) all restricted within the existing attribute parser rules and the functions compiling attribute code. This adds no complexity at all. > Even if we assume the implementation is only about 30 lines, it's > still extra complexity that I don't understand the benefit of. I > sincerely would like to know what advantage there is of grouped > attributes over the `@@` syntax. > > - It is equally or more verbose than `@@` in real-world use cases > You keep bringing up verbosity like our primary language design goal is to reduce it, PHP is the most verbose language I know. Everything in PHP requires more characters than in other languages. Keywords are usually long, variables need an extra $ in front. You have to use $this-> as no implicit context exists. Functions need to be prefixed by "array_", "str_" instead of methods on the objects. The primary design goal of a language construct in PHP is not to reduce verbosity. > - Adding or removing a second attribute with grouping can require > modifying multiple lines, adding unnecessary noise to diffs: > > @@SomeAttribute("value") > @@AnotherAttribute("value") # can be added/removed independently > function foo() {} > > # vs. > > @[SomeAttribute("value")] # changes to: > > @[ > SomeAttribute("value"), > AnotherAttribute("value"), # not added/removed independently > ] > function foo() {} > > - How much more added complexity will the grouped syntax require if > we add nested attributes in the future? At the least it will have to > be special-cased in some way, either to disallow grouping for nested > attributes or to treat the grouped syntax the same as an array. > `@@` avoids the need for additional complexity, special cased syntax, > and having to modify extra lines when adding/removing separate > attributes. > > > > - It is conceptually closest to the docblock syntax the PHP > > > community is familiar with > > > > Well, if `@@` is similar to `@` (to me it isn't), we can say that > > `@[]` is also similar to `@`. > > I would agree that `@[]` is more similar than `#[]` is. But arguably > `@@` is still the closest since docblock annotations don't require > being wrapped in array brackets. But docblocks are wrapped in /** */, enclosing the whole declaration of them. Both @[] and #[] are comparable with /** */ as metadata **boundary**. The attribute itself has no symbol prefixes or alike, it's just the class name. This is a very close translation to how docblocks with userland doc-params work, in my opinion this makes all enclosed syntaxes much more in line with existing syntax, regardless of symbols used. > > > - It is aligned with the attribute semantics of the majority of C > > > family languages > > > > In what way `#[]` or `@[]` aren't? > > The majority of C family languages use `@Attr` without an extra end > symbol. This makes sense since attributes are simply metadata > modifying the declaration that follows them, similar to visibility > and type declarations. > > Best regards, > Theodore > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --000000000000f2725605ac4571a1--