Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108932 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 21963 invoked from network); 10 Mar 2020 02:41:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Mar 2020 02:41:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BB1151804D8 for ; Mon, 9 Mar 2020 18:02:01 -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,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE 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-yw1-f67.google.com (mail-yw1-f67.google.com [209.85.161.67]) (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:02:00 -0700 (PDT) Received: by mail-yw1-f67.google.com with SMTP id t141so12108361ywc.11 for ; Mon, 09 Mar 2020 18:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=9Fv47T3xFdwF6BSNvXjjo9NPCYD6QX+waOzkTgKqsS0=; b=Wh5zRG5EKWuIpiyqjwEeN+HVDwacj1QOoYOrfpB9LpeqgSEnLc0W/60F6+UBgT45wS DCrpU+EIMC6gCQZFAH8wfD3j9qr6YcBohnTx8cuBnoZU+pl0YXoOiQRjRXFZ45WjFDCB 6SjyOc/bmVNx0u6GmwPTS1R3VljKO8oXZPs+oCEEdaKdkmjsx+PaSxze6I/iqHMAjSxZ JOpN22wWOE8DxoUrBGi0YdFEbMhmPH73iKweVcV+OI6z8IqZ2wbW0mrMvt3c/XeRu8Vh HBAYpH75jHSV2TyC5pNyhrgDVgNbHlb6+VA/CFMiozEuyf3xvtuRQjWCVuMHc+ukeS/P Ytew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=9Fv47T3xFdwF6BSNvXjjo9NPCYD6QX+waOzkTgKqsS0=; b=oh3w03ZwwsLI+U0dg0W783agjxeFAZuVr+p7DqtnZX1fpsNvjel5wJcUXTsLnryYzO JbRleTtBnVvRgMVAzUuxS1X5RmJ4BXvGlu2J56U7pOGxdcRCICP5sz/nwFKZMr50mx2X veBOn40k5s2feTSS2qB+XrMJ3m0lw19DdG7n1syQrb5Mj6Ig7tIj0Iii2SgaDFHQI8cX V+w+UEawwK+PPV1Eo3R4fi8UpVy0OlLjdEqwN/j9GaBCXURn5tKMDWfoT6BMtT7EVNfD e4zUek//iNYQDk/Xk52zJ3Efwg6mKk1Xxuie3ZdUejh6lDNKnBYy/FEqgCCvV96JroH4 GDwg== X-Gm-Message-State: ANhLgQ1DFyXvpJ//d66A9z0Cb99k0CT5ZfCO7rrjSN70OqzCBpKkrbfz baezLD3IXGa6VmI3kMUp5YUtCVmt6UJtZg== X-Google-Smtp-Source: ADFU+vsrzT5ZycidHDFzmOttqb4eBZ6mhHoqwMPgUGw8tu4KuFuIKLXs/2aMo1OwnoNAUcmx4KHbjw== X-Received: by 2002:a25:81c3:: with SMTP id n3mr18815102ybm.25.1583802120059; Mon, 09 Mar 2020 18:02:00 -0700 (PDT) Received: from ?IPv6:2601:c0:c680:5cc0:686e:ddf3:3348:93e1? ([2601:c0:c680:5cc0:686e:ddf3:3348:93e1]) by smtp.gmail.com with ESMTPSA id j187sm5356425ywg.106.2020.03.09.18.01.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Mar 2020 18:01:58 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Mon, 9 Mar 2020 21:01:57 -0400 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <2227A758-3035-4A43-974C-C4461A096DFB@newclarity.net> References: To: Benjamin Eberlei X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] [RFC] Attributes v2 From: mike@newclarity.net (Mike Schinkel) > On Mar 9, 2020, at 10:42 AM, Benjamin Eberlei = wrote: >=20 > Hi all, >=20 > 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. >=20 > The RFC is at https://wiki.php.net/rfc/attributes_v2 >=20 > A working patch is at https://github.com/beberlei/php-src/pull/2 = though > work around the details is still necessary. >=20 > 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. >=20 > There is also a fair amount of implementation detail still up for = debate, > 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. >=20 > 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 = be quite the boon. I do have a few concerns. 1. The syntax makes my eyes bleed. --------------- =20 I find angle brackets extremely hard to read and fear =E2=80=94 have = trained many newbies in programming =E2=80=94 that it will cause newbies = who see PHP to 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? =20 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=20 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=20 SingleArgument("Hello"),=20 Another\SingleArgument("World"),=20 \My\Attributes\FewArguments("foo", "bar") {}=20 2. How do your attributes relate to traits and interfaces? =20 --------------- I assume that anything you could do in a class you could do in a trait, = but what about interfaces? =20 Using my syntax, could we have attributes defines in an interface and = then require them to be implemented? For example,=20 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