Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108933 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 27004 invoked from network); 10 Mar 2020 03:16:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Mar 2020 03:16:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D600E1804D3 for ; Mon, 9 Mar 2020 18:36:45 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) (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 ; Mon, 9 Mar 2020 18:36:44 -0700 (PDT) Received: by mail-ua1-f45.google.com with SMTP id y6so2200675ual.2 for ; Mon, 09 Mar 2020 18:36:44 -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=vcnVasHi3TnQiNfWpBcp8flNFkfohYaVjh9rojgIgPk=; b=MJpJYO+Th2SOZ5QZcbGLY1Odl1Jp6tNSKgKHx0s8rLGGw75+ztnmRdnY8uyvGEQ5J9 oM+0WX/OpDdpsDwMiSZD5cBx4uEcjlSP92sALn32IoiKmrU3Xi0zHlIqsy/MRYGxdxyr PIXD1YFJd18Qafgh0GlK7Y6OHoNxcT6opDSVV9r84CAU+eX+NF8xpXdb2orBbe5pNNUv ET3Mp3qyYESM1d+9MPJfTn9T7pxY/BWHwo/QSYE/jfBK7jBhBp1Rzu16N9ArEuverAMQ CW0LK6Zb4h1dJNeq2GIeAiQz1kga/xplA0x9P0qBlqqt9/VLSUqQs8v1zApaF9eOuURJ TulQ== 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=vcnVasHi3TnQiNfWpBcp8flNFkfohYaVjh9rojgIgPk=; b=t2gSY5EMqt1AYdcGuSugS4pwSfuusLPGZX2PmoaaHPIhJld3UGsPpQzWepVALBKcbY rTHrWE5mSNiZ5i8aYeQWak9sySGDg5xoSVXFELgLxtj/aT+u+o7opq87nRTirV7mg5kx wQ+CaZl0+DRNABcy8Vz6t7V4QpkHC7BXv2cknU6Le3RGDbB4ntGGD+1a6ZTU2BvKNSZU rHE1WQxUK+QgahaHmsKHVMAu6srFQrhpkyrTqg8lLOWxwtx1DQROXN2jKJ8reVJt36We F3Ttsgz78a3yaJlFLa/uyHdrqQuIlZIjOw37/2gJelPKtQXfkYWKP/XxDVpT1TfGA8OR dkvw== X-Gm-Message-State: ANhLgQ3Z6BE0zt7nth5G0Qer8DqwDUy7fUqSRYdmM9V2sVl8l0vUXWL4 1mCirjDvsAW3yADlMP5qUHqZQGLrJuZvQZYTass= X-Google-Smtp-Source: ADFU+vtFa/5+P9fDqYSZ+nYBdssIL4OIp1Deqjqb2RLd7sMimDxBdl5Q36bvM4MknHFeQo9cNRn4ZyBojfp7A/4FZvM= X-Received: by 2002:ab0:7802:: with SMTP id x2mr10905762uaq.100.1583804200246; Mon, 09 Mar 2020 18:36:40 -0700 (PDT) MIME-Version: 1.0 References: <2227A758-3035-4A43-974C-C4461A096DFB@newclarity.net> In-Reply-To: <2227A758-3035-4A43-974C-C4461A096DFB@newclarity.net> Date: Mon, 9 Mar 2020 21:36:28 -0400 Message-ID: To: Mike Schinkel Cc: Benjamin Eberlei , PHP Internals Content-Type: multipart/alternative; boundary="000000000000bfe1b105a0762655" Subject: Re: [PHP-DEV] [RFC] Attributes v2 From: matthewmatthew@gmail.com (Matthew Brown) --000000000000bfe1b105a0762655 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Saying "the syntax makes my eyes bleed" is slightly useless feedback. You could say "it's hard to scan", but I don't even think that's true =E2= =80=93 prepending everything << makes it easy to pick out attributes in plain text at a glance, and one can assume that IDEs will help even further. Additionally this syntax has effectively been battle-tested at scale already in PHP-like codebases =E2=80=93 thousands of engineers at Facebook = and Slack have used it over the last few years, and been productive with it. On Mon, 9 Mar 2020 at 21:02, Mike Schinkel wrote: > > On Mar 9, 2020, at 10:42 AM, Benjamin Eberlei > wrote: > > > > Hi all, > > > > I want to resurrect Dmitrys Attributes RFC that was rejected for 7.1 in > > 2016 with a few changes, incorporating feedback from the mailing list > back > > then and from talking to previous no voters. > > > > The RFC is at https://wiki.php.net/rfc/attributes_v2 > > > > A working patch is at https://github.com/beberlei/php-src/pull/2 though > > work around the details is still necessary. > > > > The RFC contains a section with common criticism and objections to > > attributes, and I hope to have collected and responded to a good amount > > already from previous discussions. > > > > There is also a fair amount of implementation detail still up for debat= e, > > which is noted in "Open Issues". I have pre-committed to one approach, > but > > listed alternatives there. On these issues I am looking for your > feedback. > > > > greetings > > Benjamin > > I am very excited to see this. I make heavy use of pseduo-attributes in > both PhpDoc and using class constants, and having real attributes would b= e > quite the boon. > > I do have a few concerns. > > 1. The syntax makes my eyes bleed. > --------------- > > I find angle brackets extremely hard to read and fear =E2=80=94 have trai= ned many > newbies in programming =E2=80=94 that it will cause newbies who see PHP t= o think it > is too complex for them to consider learning. > > You mention that the good symbols are taken, but why limit ourselves to > symbols? Why not use words like PHP uses for other parts of the language= ? > > So instead of: > > <> > <> > <<\My\Attributes\FewArguments("foo", "bar")>> > function foo() {} > > Why not use?: > > attribute SingleArgument("Hello") > attribute Another\SingleArgument("World") > attribute \My\Attributes\FewArguments("foo", "bar") > function foo() {} > > If we don't want to make attribute a keyword, why not this?: > > function attribute SingleArgument("Hello") > function attribute Another\SingleArgument("World") > function attribute \My\Attributes\FewArguments("foo", "bar") > function foo() {} > > Or?: > > function attributes > SingleArgument("Hello"), > Another\SingleArgument("World"), > \My\Attributes\FewArguments("foo", "bar") > function foo() {} > > Alternately, why not use this (which is probably the best option IMO)?: > > function foo() attributes > SingleArgument("Hello"), > Another\SingleArgument("World"), > \My\Attributes\FewArguments("foo", "bar") {} > > > 2. How do your attributes relate to traits and interfaces? > --------------- > > I assume that anything you could do in a class you could do in a trait, > but what about interfaces? > > Using my syntax, could we have attributes defines in an interface and the= n > require them to be implemented? For example, > > > interface Storable attributes > StorageEngine(string $engine), > DoNotTestMethodsPrefixedWith(string $prefix){ > function store() attributes PermissionsRequired(string $role) {} > } > > When implemented that might look like this: > > class AdminOnly() implements Storable attributes > StorageEngine("mongodb"), > DoNotTestMethodsPrefixedWith("_"){ > function store() attributes PermissionsRequired("admin") {} > ... > } > > Other than those two concerns, I'm sold! > > -Mike > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --000000000000bfe1b105a0762655--