On Wed, Feb 20, 2013 at 12:12 AM, Nikita Nefedov <inefe...@gmail.com> wrote:

> On Tue, 19 Feb 2013 19:10:22 -0000, Rasmus Lerdorf <ras...@lerdorf.com>
> wrote:
>
>  On 02/19/2013 03:07 PM, Nikita Nefedov wrote:
>>
>>  Are you grepping for all the functions or you are grepping just for some
>>> specific function? If so, you are likely already know what visibility
>>> this function has, so couldn't you grep for `public %functionName%`
>>> instead of `function %functionName%`?
>>> At the end, you can always use `grep
>>> '(function|public|private|**protected) functionName' file`, and if it's
>>> long to type, you can make sh script, or even alias.
>>>
>>
>> public is the default visibility so it is often left off, so no, I can't
>> grep for that.
>>
>> -Rasmus
>>
>
> As Sara noted, we shouldn't let users define methods without modifiers at
> all, so at least public/private/protected will have to be there.
>
>
So omitting function is good because it saves keystrokes and you can still
(ab)use the visibility modifiers for grepping, and that shouldn't be
omitted anyway because having explicit visibility over saving a couple of
keystrokes is a good thing as Sara noted™.

Changing the language so the visibility modifiers are mandatory would cause
a little bit more visible/explicit declarations(only a little bit, because
it is really easy to remember what is the default visibility), and it would
require to change/fix a large amount of code but automating that would be
fairly trivial (one could even do it using grep :P).
Making the function keyword optional would cause no BC issues, and it would
make possible to write more javaish looking code, which would perceived as
a good thing by some peple, and ofc it would save us typing out the
function keyword (btw. my IDE autocompletes that so that would only spare
me 3 keystrokes).
On the other hand it would make parsing/grepping php code a little bit more
difficult and can cause some issues later on (eg. if the function keyword
is optional and we add features like accessors/etc. later on, they need to
have more explicit declaration or will be more confusing to read).

Personally I agree with Zeev and co that changing the language should be
always done when the pros clearly outweights the cons and I think that this
isn't the case here.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

Reply via email to