Hello there.
I would intend a proposal about body-less methods.
You can read RFC draft here: https://github.com/php/php-src/issues/8420
The similar topic about body-less constructors was discussed a year
ago (https://externals.io/message/114324).
There wasn't consensus in the discussion and RFC has not been created.
My proposal describes the ability to make body-less methods and constructors.
I focus on Developer eXperience and language consistency.
I made an implementation and I am ready to update it on RFC changes.
Also I need RFC carma to move it in the PHP wiki.
Feedback is welcome. Thank you.
Hi Rox,
I focus on Developer eXperience and language consistency.
When you have karma to write the RFC, you should probably include in
the text why having an extra piece of capability in the language (i.e.
one more thing to learn), that only saves two characters is a better
DX than the current situation.
In particular, as it's a slightly different meaning from the other
places where no body is allowed, as Guilliam Xavier wrote in
https://externals.io/message/114324#114334:
To me ; means not "empty body" (that's {}) but really "no definition,
only declaration" (or "no body, only signature", and also "no code
executed"), i.e. an abstract method (either explicitly declared so in a
class, or implicitly in an interface).
It's not obvious to me that body-less methods would be 'consistent'.
btw, there's a reasonable chance that whether people like the general
idea or not is an aesthetic choice, and so people will either like the
idea or not based on instinct rather than 'logic'. By spelling out why
you think it's better, rather than assuming people will agree with
that, would probably give the RFC the best chance of succeeding.
cheers
Dan
Ack