On 27 September 2020 09:22:48 BST, Nicolas Grekas <nicolas.gre...@gmail.com> wrote: >The A. syntax is consistent with the 1. list. >I feel like syntax B is not desired and could be confusing from a >grammar >pov. >BUT in syntax 2., we allow an attribute to be unprefixed (bar), so that >syntax B is consistent with 2.
I think it's fairly straightforward to see #[...] as meaning "list of attributes", rather than as "change meaning of all identifiers recursively". So, this will look for a constant "MAGIC", not a nested attribute: #[Foo(true, 42), Bar(MAGIC)] class X ... Nested attributes are a slightly confusing concept anyway, because "normal" attributes are always attached to something, but nested attributes occur in place of a normal value. I can see their usefulness, but having the extra #[...] to say "not a normal value, extra magic happening here" seems sensible. Presumably we could also allow grouping of nested attributes such that this: #[Foo(#[Bar, Baz]) class X ... Would just be equivalent to this: #[Foo([ #[Bar], #[Baz] ]) class X ... Regards, -- Rowan Tommins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php