On Sun, Jun 7, 2020, at 11:36 PM, Theodore Brown wrote:

> > Bracket-based syntaxes, particularly with grouping, are more clearly 
> > separated from the main code, particularly when used inline. For instance:
> > 
> > `$f = @@Something @@AnotherThing function(@@Special @@ReallyInt int $var) 
> > {};`  
> > vs  
> > `$f = <<Something, AnotherThing>> function(<<Special, ReallyInt>> int $var) 
> > {};`
> 
> To me there doesn't seem to be a big difference in readability between
> the function attributes in this example. And with syntax highlighting,
> the function keyword itself provides a very clear separation.
> 
> For the parameter attributes, the `@@` syntax example is actually
> more readable to my eye. I can't help seeing the `>>` token as a
> shift operator at first glance in this context.
> 
> > Finally, typing up those examples, it occurs to me that `@@` is quite a 
> > "heavy" symbol - it has a large proportion of black (or whatever colour) 
> > pixels - and inevitably a rather "fussy" one. I find it draws the eye 
> > more than the angle-brackets do, which feels unfortunate.
> 
> I guess this is somewhat dependent on the font you're using. But in
> general I don't think that the symbol being "heavy" is necessarily
> a bad thing. It can help attributes stand out better from function
> calls, generics, and other nearby syntax.
> 
> Best regards,  
> Theodore
> 
> [1]: https://wiki.php.net/rfc/attributes_v2#use_cases

FWIW, I find both alternatives ugly to my eye.  So, there's that.  

Given that @ is off the table for obvious reasons, my preference would frankly 
be for Rust's #[], which has the nice side effect of being a normal comment in 
earlier PHP versions and so attributes can be included as optional without 
breaking BC.  I don't know if that's a big deal or not, but it's a benefit.  
And it should be no harder on the parser to differentiate than @ vs @@ is.

(The only advantage of @@ in my mind is another obvious Star Wars joke.)

Something that I don't think has been addressed explicitly in this thread yet 
is single line vs separate line attributes.  Vis:

<<Foo>> class Blah {}

vs.

<<Foo>>
class Blah {}

Syntactically both are legal AFAIK; I don't know which most people will do.  
The separate line version seems more likely, and cleaner to me, but for 
parameters people may want to inline it in shorter signatures.  Or it may push 
people to always multi-line those function definitions, for better or worse.  
(I find that quite ugly myself, but I don't know if I'm in the majority on that 
view.)

My gut feeling is that @@ is notably worse inline.  It subjectively feels 
messier because there's no clear indication of where the end is.  On separate 
lines, @@ and << >> seem about equally ugly to me.

--Larry Garfield

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to