Re: [RFC] Shorter attribute syntax

From: Date: Sat, 06 Jun 2020 12:06:03 +0000
Subject: Re: [RFC] Shorter attribute syntax
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-110400@lists.php.net to get a copy of this message
Hi Theodore,

Firstly, sorry if my previous e-mail came across overly negative, I wasn't in the best mood when I wrote it (gestures vaguely at the state of the world).


I think this is possibly the best line I've read all week:

Well, I guess the line between objective and subjective may sometimes be a bit subjective. :)
Ultimately, it all comes down to judgement calls - is the double-angle-bracket syntax "too verbose", "too ugly" when nested, etc; and does the double-at syntax make it "better enough". So I'll try not to get into endless back-and-forth on every point, and just pick up on a couple of things. On 04/06/2020 23:20, Theodore Brown wrote:
Also, grouped attributes would probably have to be special-cased to be disallowed in nested attributes, since they don't make sense there.
I'm not entirely clear how they work in current implementations like Doctrine's, but I think nested attributes would have to have completely different rules anyway, because you don't access them directly through reflection in the same way. If <<Foo( <<Bar>> )>> means something like "new Foo( new Bar )", then I can imagine it being useful for <<Foo( <<Bar, Baz>> )>> to mean "new Foo( [new Bar, new Baz] )". That would actually be more convenient than the double-at version, where you'd have to write @@Foo( [ @@Bar, @@Baz ] ) or use a constructor with a ...$variadic parameter.
I don't understand how it's disingenuous. The RFC refers to the shift tokens as such because that's what they are (T_SL and T_SR). The proposed @@ syntax uses a new T_ATTRIBUTE token.
The "::" token in the parser is called T_PAAMAYIM_NEKUDOTAYIM, and personally I find T_SL and T_SR just as cryptic and irrelevant. The most common place I see those token names is when accidentally running code with conflict markers like "<<<<<<<<", or when messing up heredoc syntax; even if they weren't so abbreviated, my reaction would be "shift what now?" I've used bit-shifts maybe twice in the last ten years, so it's just not an immediate association to me. "Disingenuous" was probably too strong a word, but I do think it relates to a fundamental difference in viewpoint: to some people, << and >> are first and foremost the shift-left and shift-right operators, and so the immediate association on seeing them is so obvious it's not worth mentioning; to others, they just look like a new kind of brackets. That association might actually be a good reason to avoid that syntax, but if so it should be spelled out, rather than taken as a given. Regards, -- Rowan Tommins (né Collins) [IMSoP]

Thread (41 messages)

« previous php.internals (#110400) next »