[PHP-DEV] Re: The @@ is terrible, are we sure we're OK with it?

2020-07-23 Thread Mark Randall

On 22/07/2020 13:00, Derick Rethans wrote:

- There are lots of grumbles, both on here, room 11, as well as in the
   wider community (https://www.reddit.com/r/PHP/comments/hjpu79/it_is/)


From discussions in R11 I want to offer the following example of why 
either option with a closing tag is preferable to allow maximum 
flexibility in future development.


Assume we want to extend attributes to include something a lot of PHP 
features have, an access scope, to only allow accessing annotations from 
within the class itself, or a descendant.


Then we end up with something like :

class Foo {
  @@protected Attr protected int $bar;
}

Contrast that to something with opening and closing tags where they are 
clearly grouped:


class Foo {
  #[protected Attr] protected int $bar;
}



What other syntax might we want to add? Perhaps we want to add a way to 
enforce validation at encounter time with a "checked" keyword.


@@checked protected Attr(1,2,3) protected int $bar

#[checked protected Attr(1,2,3)] protected int $bar

It's much less ambiguous what belongs to what.



Now we could dig ourselves out of this hole using additional tokens 
around @@ such as @@(checked protected Attr) but at which point why not 
just use a mechanism that supports it out of the box?


Mark Randall

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



[PHP-DEV] Re: The @@ is terrible, are we sure we're OK with it?

2020-07-22 Thread Mark Randall

On 22/07/2020 13:00, Derick Rethans wrote:

I know we've voted twice on this already, but are we really sure that
the @@ syntax is a good idea?


No, no we are not.

We've already found one gaping hole in it, we will likely find more. Why 
knowingly back ourselves into a corner when there are perfectly good 
alternatives?


Mark Randall
marand...@php.net

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