Re: Optional constructor body
| From: | Gina P. Banyard | Date: | Thu, 18 Jul 2024 19:23:41 +0000 |
| Subject: | Re: Optional constructor body | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-124495@lists.php.net to get a copy of this message | ||
On Thursday, 18 July 2024 at 19:23, Tim Düsterhus <tim@bastelstu.be> wrote:
> On 7/18/24 16:03, Lily Bergonzat wrote:
>
> > I feel like the more substantial one would be more likely to break
> > stuff, compared to the minor one, and so I don't see why the minor one
> > would be refused?
>
>
> There is no such thing as a minor syntax change. Any changes to the
> syntax has consequences for all the downstream tools trying to
> understand PHP. This includes IDEs, static analyzers, code formatting
> and linting tools, which would all need to be updated to understand the
> new syntax. Furthermore the syntax would need to be documented and
> translated within the PHP documentation.
>
> That's quite a bit of effort to save a single character per class
> definition. In practice it will be even fewer, because not every class
> will have an empty constructor. Also whenever a class gets a non-trivial
> constructor in the future, the diff would not just consist of inserting
> the new code into the body, but also replacing the semicolon by braces,
> making the diff less readable.
>
> I do not think this is worth it.
>
> Best regards
> Tim Düsterhus
I am also of the same opinion.
The benefit of this is marginal.
And if this requires a semicolon, the benefit is even lower by effectively just typing one less
character.
Best regards,
Gina P. Banyard