On 20.02.2013, at 1:42, Sanford Whiteman 
<swhitemanlistens-softw...@cypressintegrated.com> 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.
> 
> So this works in a class to define the function:
> 
> function my_function() { }
> 
> And I expect to be able to pull that out into the global scope as-is.
> 
> But if people start using this super-shorthand in the class:
> 
> my_function() { }
> 
> Then when I pull it out into my function library, I'll get errors.
> 
> 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.
> 
> 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. And 
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 you 
to write any keyword, so you are actually can declare a method just with 
foo(){}, but it is absolutely doable, i'm just from my cell phone now.


What about readability - removal of this keyword will make a better readability 
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/declaration, but it's usually a pair of brackets. This function 
keyword is just noise for now, it doesn't serve any purpose aside from typing 
grep 'function funcname' 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 are probably familiar with 
creating 'shortcuts' for it, scripts or aliases.


Now what I think about all this "give the arguments" - the thing is - function 
keyword is just redundant. It's like appendix, we just don't need it, there's 
no point in it (yeah, except grepping), and we can drop it without any bc 
breaks, so why don't just do it?
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to