Hi Theodore, > Since the #[] attribute syntax is currently winning the vote, [1] > it makes me wonder if the use of comments starting with # should be > deprecated. > > Otherwise it seems like we could be setting ourselves up for long-term > confusion between attributes and comments, and also inconsistency with > other comments (it will no longer be safe to assume that a line can be > commented out by simply adding # at the beginning). > > What do others think?
I don't use # comments in practice that much, and objected to `#[`, but I'd imagine there'd be two main objections. 1. Most significantly, existing code would break in the major version where the deprecation became an error. So libraries that stopped being maintained in 2020 or earlier would all either need to be forked (and forks would have to be published to composer), locally checked in, be affected by a post-install script, etc - non-technical users of PHP applications may not do that and delay upgrade to php 9.0 or 10.0. I imagine there may be very strong objections to that from others, but may be wrong, since the invalid # comments would be easy to check for and automatically fix. 2. Now that we're probably going to reuse `#<rest>` for one thing, we may end up using it for other things that would benefit from forwards compatibility now that applications are already forced to deal with this lexing change. ------ Some examples of what php developers hypothetically could do by continuing to repurpose #. (I have no plans to put any of these forward as RFC) ``` declare( strict_types = 1, #php8.1 very_strict_something = 1 // #php8.1 could be a token that's treated like the end of a comment in php 8.1+ ) #[attribute] function() {/*unused closure*/}; some new php81_syntax(); // a more concise, self-explanatory version of the above that could be used in more places. #php8.1 some new php81_syntax(); // A version of assert that is guaranteed not to throw with any ini settings // and that can be optimized out in php.ini-production #expect($condition); // Adding a forward compatible syntax to declare that an argument is passed by reference // i.e. https://wiki.php.net/rfc/explicit_send_by_ref function inc(&$i) { $i++; } // instead of inc(&$i); // one of these could also be done inc(/* & */$i); inc( // or #byref #& $i ); ``` Regards, - Tyson -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php