Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66059 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10347 invoked from network); 20 Feb 2013 13:10:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2013 13:10:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.172 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.223.172 mail-ie0-f172.google.com Received: from [209.85.223.172] ([209.85.223.172:61435] helo=mail-ie0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/21-19387-C3BC4215 for ; Wed, 20 Feb 2013 08:10:20 -0500 Received: by mail-ie0-f172.google.com with SMTP id c10so9929579ieb.31 for ; Wed, 20 Feb 2013 05:10:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=gIwhIPR4RqLQ3im+DwoTw548675RSC3taoye7iWimUI=; b=LUsLLC72RENeut6kElHz8ACSTAITZxiAPmiLEfSBABo7cYe/HXHn83NTqkogFbRR7c htDw0/CQV++C5KNxDDnlW9Z050qYu/cHzy3YA9ZuKWfaoMZkBZxy8KWjFBzMenqMQRuF xTaxoKJe5c/6h6nFMCv7F75jEodUzY5Gp+HcDfvnSQNiJA9EiTBOMDkt0EfboR5/2EOh D7vv68QM944vnaUfnTZXfDLG2ICMKEukc5B4O+uH4ZgIMYzw5qew4KL0e3XWn1F+Vz1n TXYNd5jlFs4FW6iAX3Q6CTq/lbkwsE/HrczmeOpxpSk7b51pVgEACJ3VZVfGPL2jN3OL M4TQ== MIME-Version: 1.0 X-Received: by 10.50.180.228 with SMTP id dr4mr10405741igc.17.1361365818031; Wed, 20 Feb 2013 05:10:18 -0800 (PST) Received: by 10.50.114.137 with HTTP; Wed, 20 Feb 2013 05:10:17 -0800 (PST) In-Reply-To: References: <5123BE51.7060500@oracle.com> <5123CE1E.5020500@lerdorf.com> Date: Wed, 20 Feb 2013 14:10:17 +0100 Message-ID: To: Nikita Nefedov Cc: Rasmus Lerdorf , Christopher Jones , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=14dae93408c5fe3d6604d627add1 Subject: Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc From: tyra3l@gmail.com (Ferenc Kovacs) --14dae93408c5fe3d6604d627add1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Feb 20, 2013 at 12:12 AM, Nikita Nefedov wrote= : > On Tue, 19 Feb 2013 19:10:22 -0000, Rasmus Lerdorf > wrote: > > On 02/19/2013 03:07 PM, Nikita Nefedov wrote: >> >> Are you grepping for all the functions or you are grepping just for som= e >>> 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=E2=84=A2. 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. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --14dae93408c5fe3d6604d627add1--