Suggestion

php.internals

Mathias Grimm

10 years ago
Hi, I have a suggestion, maybe many gave it before. My suggestion is the optional use of the keyword "function" inside classes, interfaces and traits. It would look much more clean while removing the redundancy. Cheers, Mathias Grimm

Kalle Sommer Nielsen

10 years ago
Hi Mathias 2016-08-29 15:03 GMT+02:00 Mathias Grimm <mathiasgrimm@gmail.com>:
> Hi, > I have a suggestion, maybe many gave it before. > > My suggestion is the optional use of the keyword "function" inside classes, > interfaces and traits. > It would look much more clean while removing the redundancy.
This was discussed on internals 2 years ago, back when PHP7 was being designed: http://marc.info/?t=141235344900003&r=1&w=2
-- regards, Kalle Sommer Nielsen kalle@php.net

Mathias Grimm

10 years ago
Hi, Thanks Seems like is not going to happen very soon :) In fact it is not broken, it's only a cosmetic nice to have. Maybe in the future it will happen. On 29 August 2016 at 14:06, Kalle Sommer Nielsen <kalle@php.net> wrote:

Arvids Godjuks

10 years ago
As was said, this was debated a lot. Both sides had valid arguments, but this should not be taken lightly just because there is no "BC break". There is such thing as too much syntactic sugar, and PHP is one of those, rare these days, languages that keep options of doing the same thing low. On Mon, 29 Aug 2016, 16:16 Mathias Grimm, <mathiasgrimm@gmail.com> wrote:

Yasuo Ohgaki

10 years ago
On Mon, Aug 29, 2016 at 10:22 PM, Arvids Godjuks <arvids.godjuks@gmail.com> wrote:
> As was said, this was debated a lot. Both sides had valid arguments, but > this should not be taken lightly just because there is no "BC break". There > is such thing as too much syntactic sugar, and PHP is one of those, rare > these days, languages that keep options of doing the same thing low.
I remember an argument that "function" is useful to "grep functions". This is true, but we have tokenizer and tokenizer does better job. e.g. It excludes functions inside comments. It may be time to consider simplifying things. Regards,
-- Yasuo Ohgaki yohgaki@ohgaki.net

Robert Williams

10 years ago
On Aug 31, 2016, at 11:49, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> > I remember an argument that "function" is useful to "grep functions". > This is true, but we have tokenizer and tokenizer does better job. > e.g. It excludes functions inside comments. > > It may be time to consider simplifying things.
Perhaps, but I would typically be doing something like this when I’ve opened a PHP file in a basic text editor and am trying to find where a function is declared rather than used. The tokenizer is of no help in this use-case. Plus, I happen to like having a consistent item to lock onto visually — always hated missing that in languages that don’t have it. (For the same reason, I much prefer the function’s return type at the end rather than at the beginning of the line.)
-- Bob Williams

Marco Pivetta

10 years ago
On Thu, Sep 1, 2016 at 3:06 AM, Robert Williams <rewilliams@newtekone.com> wrote:
> On Aug 31, 2016, at 11:49, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > > > I remember an argument that "function" is useful to "grep functions". > This is true, but we have tokenizer and tokenizer does better job. > e.g. It excludes functions inside comments. > > It may be time to consider simplifying things. > > > Perhaps, but I would typically be doing something like this when I’ve > opened a PHP file in a basic text editor and am trying to find where a > function is declared rather than used. The tokenizer is of no help in this > use-case. Plus, I happen to like having a consistent item to lock onto > visually — always hated missing that in languages that don’t have it. (For > the same reason, I much prefer the function’s return type at the end rather > than at the beginning of the line.) > > -- > Bob Williams >
Yeah, and I would question: 1. why are you editing with a plaintext editor and searching stuff like that? Are you in a super-hurry? Seems like a 0.001% scenario 2. why do you need to search for functions in a class? Just what kind of monstrous abomination are you working on? Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/

Rowan Collins

10 years ago
On 01/09/2016 13:12, Marco Pivetta wrote:
> Yeah, and I would question: > > 1. why are you editing with a plaintext editor and searching stuff like > that? Are you in a super-hurry? Seems like a 0.001% scenario > 2. why do you need to search for functions in a class? Just what kind of > monstrous abomination are you working on?
I think this conversation is going nowhere. We can equally ask hypothetical questions the other way: - Why do you find the word "function" so hard to type? Are you in a super-hurry? - Why are your function declarations so long that you need to save 8 characters? What kind of abomination are you working on? etc etc There really isn't that much to say either way: some people like having the keyword introduce each declaration, some people don't. Can we just agree that it's a matter of style? If we were designing a new language, we could vote on what consistent style we wanted to create. With 20 years of existing language history, there's always going to be a bias towards keeping things as they are. Regards,
-- Rowan Collins [IMSoP]