Re: [PHP-DEV] Re: [RFC] [VOTE] Shorter Attribute Syntax
On Thu, July 2 2020 at 8:14 AM Nikita Popov wrote: > On Thu, Jul 2, 2020 at 2:13 AM Theodore Brown wrote: > > On Wed, June 17, 2020 at 5:59 PM Theodore Brown wrote: > > > > > I've opened voting on the Shorter Attribute Syntax RFC: > > > https://wiki.php.net/rfc/shorter_attribute_syntax > > > > > > Since all RFCs require a primary vote with a 2/3 majority, there is > > > a main vote to approve the secondary ranked-choice vote. > > > > > > For the ranked-choice poll, fill in your first through third syntax > > > choices, making sure not to select the same syntax more than > > > once. You don't have to vote for all three options, but please > > > don't leave gaps. > > > > > > Voting will end in two weeks, on 2020-07-01. > > > > Hi internals, > > > > The Shorter Attribute Syntax RFC vote is now closed. The primary poll > > for re-voting on attribute syntax was approved with 50 in favor and 8 > > opposed. > > > > For the secondary ranked-choice poll there are 61 valid ballots. Since > > only one syntax can be elected, the quota is floor(61 / 2) + 1 = 31. > > > > Note: one ballot wasn't counted since it selected the same syntax > > more than once. However, this does not change the vote outcome. > > > > In the first round the tally is as follows: > > > > @@: 34 votes > > #[]: 21 votes > > <<>>: 6 votes > > > > So @@ reaches the quota and has been elected as the final attribute > > syntax for PHP 8. > > > > Thank you to everyone who voted! > > > Hi Theodore, > > Unfortunately, the RFC failed to mention a small, but important detail: > The @@ syntax is ambiguous, as pointed out by Martin Schröder: > > function (@@X \ Y $param) { } > > Taking into account that PHP allows whitespace between namespace > separators, this can either be interpreted as an attribute "X\Y" on an > untyped parameter, or as an attribute "X" on a "\Y" typed parameter. > > The RFC implementation solves this by treating @@ and the following name > as a single token that does not permit whitespace. As such, it will be > interpreted as "X" with an "\Y" typed parameter. > > Now, if this had been explicitly mentioned in the RFC, we could have made > an explicit decision to accept this language inconsistency: To forbid > whitespace in namespaced names for attributes only, unlike all other > places in PHP accepting namespaced names. However, it was not mentioned > in the RFC, and apart from the authors of the proposal, I don't think > anyone was aware of this ambiguity. > > Fortunately, there is still a way to resolve this issue in a consistent > manner: Change the handling of namespaced names in PHP in general. This > is exactly what is proposed in > https://wiki.php.net/rfc/namespaced_names_as_token. > If that proposal is accepted, then the ambiguity would disappear (and > the above example would become a parse error). > > My plan would be to change the > https://wiki.php.net/rfc/namespaced_names_as_token > proposal to either only deal with the handling of namespaced names > (i.e. as a single, whitespace-free token), or at least separate the > other reserved keyword related changes into a separate vote. > > If that proposal passes, then there should be no issue with adopting the > @@ syntax for attributes (unless there are other problems I'm not aware > of?) If it does not pass, then we'll have to discuss what we want to do > here. Hi Nikita, Thanks for bringing this up. The original Attributes v2 RFC mentioned that the shorter @: syntax "does not permit whitespace in attribute names to allow detecting the ending of the declaration", but when I wrote the new RFC I didn't think to mention that this applies to @@ as well (the implementation is almost exactly the same). It certainly could be considered inconsistent that whitespace is allowed in most namespaced names, but not attributes. On the other hand, since attributes are new syntax anyway it's arguably okay for them to have stricter semantics. But I agree that the ideal solution would be to change the handling of namespaced names in general, per your https://wiki.php.net/rfc/namespaced_names_as_token RFC. This would also have the benefit of minimizing the impact of reserving new keywords. Best regards, Theodore -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php
Re: [PHP-DEV] Re: [RFC] [VOTE] Shorter Attribute Syntax
On Thu, Jul 2, 2020 at 2:13 AM Theodore Brown wrote: > On Wed, June 17, 2020 at 5:59 PM Theodore Brown wrote: > > > I've opened voting on the Shorter Attribute Syntax RFC: > > https://wiki.php.net/rfc/shorter_attribute_syntax > > > > Since all RFCs require a primary vote with a 2/3 majority, there is > > a main vote to approve the secondary ranked-choice vote. > > > > For the ranked-choice poll, fill in your first through third syntax > > choices, making sure not to select the same syntax more than > > once. You don't have to vote for all three options, but please > > don't leave gaps. > > > > Voting will end in two weeks, on 2020-07-01. > > Hi internals, > > The Shorter Attribute Syntax RFC vote is now closed. The primary poll > for re-voting on attribute syntax was approved with 50 in favor and 8 > opposed. > > For the secondary ranked-choice poll there are 61 valid ballots. Since > only one syntax can be elected, the quota is floor(61 / 2) + 1 = 31. > > Note: one ballot wasn't counted since it selected the same syntax > more than once. However, this does not change the vote outcome. > > In the first round the tally is as follows: > > @@: 34 votes > #[]: 21 votes > <<>>: 6 votes > > So @@ reaches the quota and has been elected as the final attribute > syntax for PHP 8. > > Thank you to everyone who voted! > Hi Theodore, Unfortunately, the RFC failed to mention a small, but important detail: The @@ syntax is ambiguous, as pointed out by Martin Schröder: function (@@X \ Y $param) { } Taking into account that PHP allows whitespace between namespace separators, this can either be interpreted as an attribute "X\Y" on an untyped parameter, or as an attribute "X" on a "\Y" typed parameter. The RFC implementation solves this by treating @@ and the following name as a single token that does not permit whitespace. As such, it will be interpreted as "X" with an "\Y" typed parameter. Now, if this had been explicitly mentioned in the RFC, we could have made an explicit decision to accept this language inconsistency: To forbid whitespace in namespaced names for attributes only, unlike all other places in PHP accepting namespaced names. However, it was not mentioned in the RFC, and apart from the authors of the proposal, I don't think anyone was aware of this ambiguity. Fortunately, there is still a way to resolve this issue in a consistent manner: Change the handling of namespaced names in PHP in general. This is exactly what is proposed in https://wiki.php.net/rfc/namespaced_names_as_token. If that proposal is accepted, then the ambiguity would disappear (and the above example would become a parse error). My plan would be to change the https://wiki.php.net/rfc/namespaced_names_as_token proposal to either only deal with the handling of namespaced names (i.e. as a single, whitespace-free token), or at least separate the other reserved keyword related changes into a separate vote. If that proposal passes, then there should be no issue with adopting the @@ syntax for attributes (unless there are other problems I'm not aware of?) If it does not pass, then we'll have to discuss what we want to do here. Regards, Nikita
[PHP-DEV] Re: [RFC] [VOTE] Shorter Attribute Syntax
On Wed, June 17, 2020 at 5:59 PM Theodore Brown wrote: > I've opened voting on the Shorter Attribute Syntax RFC: > https://wiki.php.net/rfc/shorter_attribute_syntax > > Since all RFCs require a primary vote with a 2/3 majority, there is > a main vote to approve the secondary ranked-choice vote. > > For the ranked-choice poll, fill in your first through third syntax > choices, making sure not to select the same syntax more than > once. You don't have to vote for all three options, but please > don't leave gaps. > > Voting will end in two weeks, on 2020-07-01. Hi internals, The Shorter Attribute Syntax RFC vote is now closed. The primary poll for re-voting on attribute syntax was approved with 50 in favor and 8 opposed. For the secondary ranked-choice poll there are 61 valid ballots. Since only one syntax can be elected, the quota is floor(61 / 2) + 1 = 31. Note: one ballot wasn't counted since it selected the same syntax more than once. However, this does not change the vote outcome. In the first round the tally is as follows: @@: 34 votes #[]: 21 votes <<>>: 6 votes So @@ reaches the quota and has been elected as the final attribute syntax for PHP 8. Thank you to everyone who voted! Theodore -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php
Re: [PHP-DEV] Re: [RFC] [VOTE] Shorter Attribute Syntax
On Thu, June 18, 2020 at 8:40 AM Mark Randall wrote: > On 18/06/2020 00:59, Theodore Brown wrote: > > I've opened voting on the Shorter Attribute Syntax RFC: > > https://wiki.php.net/rfc/shorter_attribute_syntax > > I'd be wary of @@ simply because if we do add validation to them, > we would likely want to use the suppression operator to indicate > that a class might be omitted (such as if an optional package is > not installed). > > At which point we're left with @@@ and that's getting into silly-land. Hi Mark, Attributes were already designed to be optional, though, so there's no need to suppress anything. Attribute validation occurs when you call `ReflectionAttribute::newInstance()`. Or are you suggesting that we reverse the way this works, and always validate attributes unless a suppression operator is used? I'm not convinced this is a good idea - it would require adding a suppression operator for all the use cases where attribute information is collected without an attribute class, which changes something that should be an internal implementation detail to require different syntax for end-users of a library. Also, it could be confusing if the suppression operator only prevents autoloading, but doesn't suppress other warnings. And if it does suppress other warnings, that would probably not be what developers want in most cases. Lastly, in my personal opinion combining the suppression operator with attribute declarations looks like even worse symbol soup with with the other syntax options. :) Best regards, Theodore -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php
[PHP-DEV] Re: [RFC] [VOTE] Shorter Attribute Syntax
On 18/06/2020 00:59, Theodore Brown wrote: I've opened voting on the Shorter Attribute Syntax RFC: https://wiki.php.net/rfc/shorter_attribute_syntax I'd be wary of @@ simply because if we do add validation to them, we would likely want to use the suppression operator to indicate that a class might be omitted (such as if an optional package is not installed). At which point we're left with @@@ and that's getting into silly-land. Mark Randall marand...@php.net -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php