Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66024 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41067 invoked from network); 20 Feb 2013 08:16:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2013 08:16:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.181 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.217.181 mail-lb0-f181.google.com Received: from [209.85.217.181] ([209.85.217.181:47450] helo=mail-lb0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AF/43-19387-57684215 for ; Wed, 20 Feb 2013 03:16:54 -0500 Received: by mail-lb0-f181.google.com with SMTP id gm6so5649119lbb.26 for ; Wed, 20 Feb 2013 00:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:subject:references:from:content-type:x-mailer :in-reply-to:message-id:date:to:content-transfer-encoding :mime-version; bh=rMiNWSM6W4Lye/nrorIKevGDoDY3Hsn03DqBJibMxZI=; b=l5pE5zbJN+Fo57XFtiQUxEV3qddpTzKxVT9r+ImOTKlRbqfaacN6BhVCWuF2urNVKM 9O4YhyXxGuczelolGH+CW5PVmMIESHLLX6UUTolzoVwtb4JcRzoBK1xCIyactZgEiBpc ZhXepToP8JncjjeYk/7+2WaaKOFUVWx1A8N9nMAPL4DMKt8WVddQO1Bg/RyVckCv8QWr 8pwmpDA5gbP/174QGFe+nRsgA0bpCITvjwED5nTTfQAW3djmTqmgTRfpbJwAH+KqHmED PrxgQF1Oa+GNcI2ZwX5NDRfN/IRxD5IhdGlcGUSqc+PkvIF8SsSnXLXspCeUU6lmjzgx 8+Ow== X-Received: by 10.152.109.208 with SMTP id hu16mr10100039lab.45.1361348210318; Wed, 20 Feb 2013 00:16:50 -0800 (PST) Received: from [192.168.1.7] (37-144-174-250.broadband.corbina.ru. [37.144.174.250]) by mx.google.com with ESMTPS id hk10sm8501501lab.4.2013.02.20.00.16.49 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Feb 2013 00:16:49 -0800 (PST) References: <5123BE51.7060500@oracle.com> <5123CE1E.5020500@lerdorf.com> <1586876476.20130219164246@cypressintegrated.com> Content-Type: text/plain; charset=us-ascii X-Mailer: iPod Mail (10A523) In-Reply-To: <1586876476.20130219164246@cypressintegrated.com> Message-ID: <407C7FA9-ABA7-4C01-A04C-AEA056F372FB@gmail.com> Date: Wed, 20 Feb 2013 12:19:27 +0400 To: Sanford Whiteman , "internals@lists.php.net" Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) Subject: Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc From: inefedor@gmail.com (Nikita Nefedov) On 20.02.2013, at 1:42, Sanford Whiteman wrote: > Seems this would complicate the transplanting of (global) functions > into (default public) class methods and vice versa. This is a common > refactoring task -- at least IME -- and before I adjust visibility I > would expect the function to Just Work. >=20 > So this works in a class to define the function: >=20 > function my_function() { } >=20 > And I expect to be able to pull that out into the global scope as-is. >=20 > But if people start using this super-shorthand in the class: >=20 > my_function() { } >=20 > Then when I pull it out into my function library, I'll get errors. >=20 > The reverse is also true: I expect to get a fatal from leaving off a > semicolon between function_call() and {} but at the top level of a > class it gets smoothly compiled as a function definition. >=20 > Look, I know there are similar cases throughout PHP (and other > languages) already, but why add more for no (IMO) payoff? Perhaps not > the most compelling case against this new sugar, but it would suffice > to stop me from ever using it. Hi Sandy, it won't complicate you anything. Global functions remain its requirement for keyword, just methods lose it. A= nd it doesn't mean that you can't write class Foo { function bar() {} } As I said, there are no bc breaks at all. My initial patch doesn't forces yo= u to write any keyword, so you are actually can declare a method just with f= oo(){}, but it is absolutely doable, i'm just from my cell phone now. What about readability - removal of this keyword will make a better readabil= ity of methods. Instead of abstract class Foo { public function make() { // some code } public abstract function do(); } You will need to read just class Foo { public make() { // some code } public abstract do(); } It's not function a keyword who lets you recognize function definition/decla= ration, but it's usually a pair of brackets. This function keyword is just n= oise for now, it doesn't serve any purpose aside from typing grep 'function f= uncname' instead of grep '(private|protected|public|abstract|static)funcname= ' , but, you know, if you love shell so much (or are forced to use it) you a= re probably familiar with creating 'shortcuts' for it, scripts or aliases. Now what I think about all this "give the arguments" - the thing is - functi= on keyword is just redundant. It's like appendix, we just don't need it, the= re's no point in it (yeah, except grepping), and we can drop it without any b= c breaks, so why don't just do it?=