Am 03.10.2014 um 19:38 schrieb Levi Morrison <le...@php.net>:

> On Fri, Oct 3, 2014 at 10:21 AM, Thomas Gossmann <m...@gossimaniac.net>
> wrote:
> 
>> Hey there,
>> 
>> I'm just a php developer, thus not even having a php.net account.
>> 
>> I was wondering if it is possible to deprecate/remove the function keyword
>> from class methods in php7 or at least make it optional when one of the
>> visibility keywords is present?
>> 
>> I feel like writing a completely unnecessary keyword each time I write a
>> new method for a class.
>> 
>> I guess this was a discussion earlier, though I wasn't able to find
>> anything about it. Would love to hear, what pdt-internals (re-)think about
>> that topic.
>> 
>> Thanks,
>> gossi
> 
> 
> Removing the function keyword makes it more difficult for people to find
> method definitions. This has historically been a significant factor in why
> this hasn't been done.
> 
> Also, what does this change actually bring to the table? There is no actual
> benefit to the language or tooling; in fact it probably makes the tooling
> more difficult. All this means is that the user types the function keyword
> less and saves a very, very small amount of time.
> 
> In summary, historically we have felt that the benefits do not outweigh the
> drawbacks.


I usually just observe on this list, but this is a topic I have come across 
myself.

PHP has followed the C++ syntax, and logical scoping like namespace,s since a 
long time - if not, eversince. C++ does not use a function keyword by itself, 
and even lesser visibility keywords as PHP does.

I find it rather ugly seeing „public function foo()“ everywhere, when everybody 
knows that parantheses mean function. So, I see readability as a plus.

<?php class Foo {
    public bar($a, $b) { return $a+$b; }
} ?>

It actually is not a drawback, but rather an enhancement that would increase 
PHP’s readability, in my opinion. It could be introduced as „syntactic 
shuggar“, where people can, but dont have to, use the function keyword. For the 
lexer, this just seems to be one more if().

I don’t see a lot of evolution in PHP lately, so something small as this might 
be pretty nice! :)
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to