11

shorter_attribute_syntax_change

 3 years ago
source link: https://wiki.php.net/rfc/shorter_attribute_syntax_change
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Introduction

With the continued discussion over the currently selected attribute syntax @@ from the Shorter Attribute Syntax RFC we want to revisit the syntax choice once and for all, so that we can be as sure as possible the right choice was picked.

There are multiple reasons why we believe the previous vote should be revisited:

  • At the point of the vote for @@, it was not clear that the syntax required the namespace token RFC to be viable. While this is not a problem anymore, the @@ syntax might not have come out on top if this information was known beforehand. A revote could dispel doubts whether @@ is still favoured by a majority.
  • The shorter attributes RFC removed the support for grouped syntaxes, which was voted on favourably in Attributes Amendments. Due to the missing namespace token RFC at that point @@ did not support grouping at that point. With the namespace token RFC it would support grouping along the lines of @@[]. As @@ still does not support grouping, voters that both favoured grouping and @@ should given a chance to decide again with full information.
  • The #[] syntax provides the benefit of forward compatibility, but this also introduces some potential problems for PHP 7 code. An alternative syntax @[] was suggested to alleviate these problems which was not previously voted on. Another new syntax proposal is @{} which has the benefit of not causing a BC break.
  • We argue why we should strongly favour a syntax with closing delimiter to keep consistency with other parts of the language and propose to use #[], @[], @{}, or the original << … >> instead.

While reasons for or against a syntax obviously include subjective opinions, please keep in mind that we want the best syntax, and not necessarily the best looking syntax.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK