Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
While I'm thinking about this (though I should leave it alone): who's to say that PHP won't some day get inner classes? By deciding the default inner member of a class will be a function, you're choosing the one that has a global/procedural equivalent where the short syntax won't work, instead of leaving the concept unused for the possible future when: class myClass { mySomething { // is equivalent to class mySomething { (Yes, you could say mySomething(...) { } is a public function and mySomething { } is an innner class, but you get the idea.) -- S. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
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
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Wed, 20 Feb 2013 08:02:36 -, Sanford Whiteman swhitemanlistens-softw...@cypressintegrated.com wrote: While I'm thinking about this (though I should leave it alone): who's to say that PHP won't some day get inner classes? By deciding the default inner member of a class will be a function, you're choosing the one that has a global/procedural equivalent where the short syntax won't work, instead of leaving the concept unused for the possible future when: class myClass { mySomething { // is equivalent to class mySomething { (Yes, you could say mySomething(...) { } is a public function and mySomething { } is an innner class, but you get the idea.) -- S. Classes always should be declared with class keyword, because there could be ambiguity whether it's class, interface or trait. Also, I will say it again: as Sara noted, we *really* shouldn't let users define methods without any modifiers, like this: class Foo { asd() { echo this is parse error; } } -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Protip: use an IDE. The IDE that i'm using may search for something like function \w to find all the functions of my code. So I may have to wait for a new update of the IDE to be able to use the index, and I also may have to pay to get the update of my IDE. So why would I want all this if I can just keep the function keyword. Pierrick
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Global functions remain its requirement for keyword, just methods lose I understand that. You didn't read my post carefully because I was noting this exact inconsistency. it. And it doesn't mean that you can't write class Foo { function bar() {} } No, it means you _have to_ write it that way if you want the same function definition to work in and out of a class. Like I said, I expect the simplest function def to Just Work (as it does now) in either scope. This is not a technical BC break but a conceptual break that disregards existing realities of refactoring (as well as realities of who writes the code we end up maintaining). 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(); } That's no more readable to me. And even if I pretended to find it so, I want to to read other contemporary languages with relative ease as well, rather than being coddled by sugar that doesn't exist in other C-style languages. PHP is not Java or C#, yes; yet the more streamlined we get while those languages are adding actual features, the worse off we'll be when we have to get the gist of something in a verbose foreign language. And I don't want to drop function on the server and then forget it in JavaScript. That's a net loss for me and the millions of other users jacking both trades. It's not function a keyword who lets you recognize function definition/declaration, but it's usually a pair of brackets. The function(){} construction is critical to recognizing a function definition. Simply looking for curly braces is not sufficient, since obviously a {} block does not mean you're in a function. {} is perhaps more predictive at the second level of a class file, but in a codebase in general it would be reckless to treat {}, or even (){}, as denoting a function definition, since the former squarely does not and the latter is more likely to mean an forgotten semicolon in real-world code. 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. I could scarcely disagree more with your minimizing view of how people seek and scan code. I think I'd better stop discussing it as well -- I don't have voting karma so good luck either way -- S. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Classes always should be declared with class keyword, because there could be ambiguity whether it's class, interface or trait. If only inner classes are allowed in a given PHP version, there's no ambiguity about whether something{} just inside a a class is an inner class. That's the justification for removing function just inside classes, isn't it? That it's not ambiguous because the only thing as of PHP.now that can take the form sometype somevisibility something(){} is a function? Well, if in PHP.later, the only thing that takes the form sometype something{} is an inner class, then leaving off the sometype there is also unambiguous (but also similarly gratuitous). And if in PHP.later.still you have inner interfaces, then the unmodified one still defaults to inner class and only a literal interface something{} is an inner intf. (I'm attempting a RAA argument but maybe failing) -- Sandy | FigureOne Support Team -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Wed, 20 Feb 2013 09:59:51 -, Sanford Whiteman swhitemanlistens-softw...@cypressintegrated.com wrote: Classes always should be declared with class keyword, because there could be ambiguity whether it's class, interface or trait. If only inner classes are allowed in a given PHP version, there's no ambiguity about whether something{} just inside a a class is an inner class. That's the justification for removing function just inside classes, isn't it? That it's not ambiguous because the only thing as of PHP.now that can take the form sometype somevisibility something(){} is a function? Well, if in PHP.later, the only thing that takes the form sometype something{} is an inner class, then leaving off the sometype there is also unambiguous (but also similarly gratuitous). And if in PHP.later.still you have inner interfaces, then the unmodified one still defaults to inner class and only a literal interface something{} is an inner intf. (I'm attempting a RAA argument but maybe failing) -- Sandy | FigureOne Support Team So no you are not saying PHP is not Java or C#. I don't want to touch any religious views but it's really funny to read :) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Sandy, On Wed, Feb 20, 2013 at 11:59 AM, Sanford Whiteman swhitemanlistens-softw...@cypressintegrated.com wrote: Classes always should be declared with class keyword, because there could be ambiguity whether it's class, interface or trait. If only inner classes are allowed in a given PHP version, there's no ambiguity about whether something{} just inside a a class is an inner class. That's the justification for removing function just inside classes, isn't it? That it's not ambiguous because the only thing as of PHP.now that can take the form sometype somevisibility something(){} is a function? Well, if in PHP.later, the only thing that takes the form sometype something{} is an inner class, then leaving off the sometype there is also unambiguous (but also similarly gratuitous). And if in PHP.later.still you have inner interfaces, then the unmodified one still defaults to inner class and only a literal interface something{} is an inner intf. (I'm attempting a RAA argument but maybe failing) -- Sandy | FigureOne Support Team I think you've abstracted this one way too much. For me right now all I see is a useless keyword in a class. We don't have 'visbilitytype var/property $varName' right now but you are comfortable with them knowing that they are just properties of the class. If I were to be on this road I could in fact argue that currently we have a lack of consistency between class methods and properties. You can have a look on this image if you want an example: http://i.imgur.com/Q0ZOZns.png For the part where public is optional, I think that most frameworks and practices they promote and users actually do type the keyword and have it there for the sake of consistency. It might not be the case for now, but I think that it would rather be useful to enforce the visibility types rather that the 'function' keyword. As for classes/interfaces/traits and so on, if they are ever added in PHP to be declared inside classes and so on then I see no issues with this. A class/interface or a trait keyword would still be needed to make the difference between a them imho. Grepping for sources is like a daily operation and by using IDEs like Netbeans/Eclipse/PHPStorm one has the ability to just search for a symbol directly, regardless if you can click of function name or not. No voting karma here as well but I do tons of code reviews and this is just my opinion, you know, from the userland. Regards. Florin Patan https://github.com/dlsniper -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
So no you are not saying PHP is not Java or C#. I don't want to touch any religious views but it's really funny to read :) Not sure I get your remark... of those languages, I've said, in essence [1] Don't *force* PHP to look less like Java, ECMAScript, C#, or C++ without a good reason and a new feature and [2] Don't preclude other languages' advanced features from being added to PHP later -- even much later -- with their most obvious syntax by clipping syntax in PHP.now so that later additions are more difficult. And PHP is looking more like ES in some ways (array literals). I like that. I don't insist on it, but it's a leg up. CF did that too a while back, and that brought me back to it for a project. As I said, if inner classes are ever added to PHP, it stands to reason they would follow the syntax of other C-style languages. And you might then apply your (I believe flawed) argument that any token that could be considered superfluous in a given parser context *and* PHP version should become optional with the default meaning being permanently fixed as of that PHP version. It doesn't stand up to scrutiny because you just end up with more magic to remember and no real advantages, especially over time. But really, really truly, I am not going to comment again on this thread but just wish you luck in swaying the people that count! Cheers, -- S. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
As for classes/interfaces/traits and so on, if they are ever added in PHP to be declared inside classes and so on then I see no issues with this. A class/interface or a trait keyword would still be needed to make the difference between a them imho. No, if you *only* allow inner classes at any point, you don't have ambiguity. So by your standard, that version of PHP should drop the keyword because there's only one unambiguous something{} construction in that context. I'm not saying you _should_ drop the keyword, I'm just explaining what I think is the slippery slope of this kind of non-improvement. Grepping for sources is like a daily operation and by using IDEs like Netbeans/Eclipse/PHPStorm one has the ability to just search for a symbol directly, regardless if you can click of function name or not. I don't think you followed the matter of complex search/replace and the new regex you'd have to just use all the time. I use a sophisticated IDE as I mentioned, but its s/r function is separate from its find declaration function. Not to mention searching for duplicate declarations or in files you don't have in your workspace. This is a real problem and I'm very happy we don't have it now. No voting karma here as well but I do tons of code reviews and this is just my opinion, you know, from the userland. I am debating from userland as well. But I'm all done w/this one. -- S. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
The key question for me is: does removing it hurt PHP in any way? And for me, the answer is a clear and resounding no. This is completely the wrong question to ask (IMHO). I think the answer is wrong too, but that's a different story. The correct question is: Does it bring substantial value to be considered for inclusion in one of the world's most popular programming languages? For me, the answer is a clear and resounding no. From my POV that's where the story ends. The whole discussion about greps and IDEs misses the point - we shouldn't even be discussing a 'feature' that brings no value to the table. The only reason I wrote my reply is that we seem to be having an influx of those RFCs that fail this very basic requirement. Zeev -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Wed, Feb 20, 2013 at 12:12 AM, Nikita Nefedov inefe...@gmail.com wrote: On Tue, 19 Feb 2013 19:10:22 -, 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
[PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Hi! As someone mentioned in the thread about short syntax for closures, we could also drop requirement for `function` keyword when defining/declaring methods in classes, interfaces or traits. I have long noticed how redundant it is. The patch is pretty easy as it was with commas :) It is absolutely backwards compatible (you can use `function` or you can not use it). Here's the patch: https://gist.github.com/nikita2206/4988075 If people will welcome this proposal, I would need some karma for making RFC. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Hi, On Tue, 2013-02-19 at 21:44 +, Nikita Nefedov wrote: Hi! As someone mentioned in the thread about short syntax for closures, we could also drop requirement for `function` keyword when defining/declaring methods in classes, interfaces or traits. I proposed this in November '10: http://news.php.net/php.internals/50628 I agreed to the conclusion that the function keyword provided a nice way to grep for functions when handling foreign code and leaving it out only provides little improvement in less typing. Please provide new arguments for a new discussion. (That thread was rather long) And as a general note I'd like to remind you all about Rasmus' recent mail: http://news.php.net/php.internals/65894 - In my words: Why not fix bugs instead of creating new ones? johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Tue, 19 Feb 2013 17:53:40 -, Johannes Schlüter johan...@schlueters.de wrote: I agreed to the conclusion that the function keyword provided a nice way to grep for functions when handling foreign code and leaving it out only provides little improvement in less typing. Please provide new arguments for a new discussion. (That thread was rather long) And as a general note I'd like to remind you all about Rasmus' recent mail: http://news.php.net/php.internals/65894 - In my words: Why not fix bugs instead of creating new ones? johannes Hmm, I agree about grepping, but how often do you do it? Actually, last time I grepped php files was half a year ago I think, when I had just ssh connection and didn't want to mount sshfs. But usually there's IDEs that can statically analyze your code and let you search against huge codebases in seconds, I don't want to sound mean, but hey, does anybody greps php code? What about reasoning - of course there's no reasons besides less typing. At the moment, usually when I want to define method, I usually already know will be in its body so I'm trying to type as fast as I can, and I often make some mistake in `public` keyword or `function`, actually it happens all the time :) So for me it would be pretty good feature if I could write one less word. I agree with Sara about requirement for explicit declaration of visibility attr. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On 02/19/2013 02:39 PM, Nikita Nefedov wrote: Hmm, I agree about grepping, but how often do you do it? Actually, last time I grepped php files was half a year ago I think, when I had just ssh connection and didn't want to mount sshfs. But usually there's IDEs that can statically analyze your code and let you search against huge codebases in seconds, I don't want to sound mean, but hey, does anybody greps php code? About 20-30 times every single day. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Rasmus Lerdorf wrote: On 02/19/2013 02:39 PM, Nikita Nefedov wrote: Hmm, I agree about grepping, but how often do you do it? Actually, last time I grepped php files was half a year ago I think, when I had just ssh connection and didn't want to mount sshfs. But usually there's IDEs that can statically analyze your code and let you search against huge codebases in seconds, I don't want to sound mean, but hey, does anybody greps php code? About 20-30 times every single day. Ditto via the Eclipse equivalent ... Has anything changed since we last discussed this? And threw it out ... -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Tue, Feb 19, 2013 at 11:53 AM, Lester Caine les...@lsces.co.uk wrote: Rasmus Lerdorf wrote: On 02/19/2013 02:39 PM, Nikita Nefedov wrote: Hmm, I agree about grepping, but how often do you do it? Actually, last time I grepped php files was half a year ago I think, when I had just ssh connection and didn't want to mount sshfs. But usually there's IDEs that can statically analyze your code and let you search against huge codebases in seconds, I don't want to sound mean, but hey, does anybody greps php code? About 20-30 times every single day. Ditto via the Eclipse equivalent ... Has anything changed since we last discussed this? And threw it out ... Yes: the dynamics of the people who vote. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Tue, 19 Feb 2013 18:02:57 -, Christopher Jones christopher.jo...@oracle.com wrote: What about including a few basic examples aka test cases in your patch? If the feature is accepted, you'll need to include a LOT of testcases. Chris Hi Chris, this code could be a basic case (just for the sake of understanding) https://gist.github.com/nikita2206/4988665 But I will add an actual tests if it's going to receive some support. On Tue, 19 Feb 2013 18:41:41 -, Rasmus Lerdorf ras...@lerdorf.com wrote: On 02/19/2013 02:39 PM, Nikita Nefedov wrote: About 20-30 times every single day. -Rasmus Hi Rasmus, 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. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Tue, 19 Feb 2013 19:10:22 -, 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. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Tue, 2013-02-19 at 23:07 +, Nikita Nefedov wrote: At the end, you can always use `grep '(function|public|private| protected) You've forgotten abstract and static (mind that we don't force the order of those) It saves 9 key strokes (while many IDEs can assist) and helps when looking for issues in foreign code bases (what many of us do) so unless there's anything new we should try to keep this list productive. 5.5 is waiting to get out. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On 20 February 2013 00:12, Nikita Nefedov inefe...@gmail.com wrote: On Tue, 19 Feb 2013 19:10:22 -, 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. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php Just a quick check: you're absolutely certain this issue isn't much better/easier handled with IDE macros/plugins? Something along the lines of zen coding? If you're really that obsessed with typing 9 characters less, you must have considered keyboard shortcuts that let you type the docblock, visibility, etc. in just 3-5 keystrokes. Just a thought from userland Peter -- hype WWW: plphp.dk / plind.dk CV: careers.stackoverflow.com/peterlind LinkedIn: plind Twitter: kafe15 /hype -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
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. -- Sandy -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Are we really trying to look under ground now for ways to change the language syntax? Unless there's a strong case to adding/removing/changing syntax, that goes well beyond 'because we can' or 'it shortens the code' it shouldn't even be brought up for discussion. Zeev On 19 בפבר 2013, at 19:44, Nikita Nefedov inefe...@gmail.com wrote: Hi! As someone mentioned in the thread about short syntax for closures, we could also drop requirement for `function` keyword when defining/declaring methods in classes, interfaces or traits. I have long noticed how redundant it is. The patch is pretty easy as it was with commas :) It is absolutely backwards compatible (you can use `function` or you can not use it). Here's the patch: https://gist.github.com/nikita2206/4988075 If people will welcome this proposal, I would need some karma for making RFC. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
2013/2/19 Nikita Nefedov inefe...@gmail.com: Hmm, I agree about grepping, but how often do you do it? Actually, last time I grepped php files was half a year ago I think, when I had just ssh connection and didn't want to mount sshfs. But usually there's IDEs that can statically analyze your code and let you search against huge codebases in seconds, I don't want to sound mean, but hey, does anybody greps php code? Yes, daily. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Tue, Feb 19, 2013 at 4:01 PM, Zeev Suraski z...@zend.com wrote: Are we really trying to look under ground now for ways to change the language syntax? Unless there's a strong case to adding/removing/changing syntax, that goes well beyond 'because we can' or 'it shortens the code' it shouldn't even be brought up for discussion. I am something of a language guru and to me syntax is *extremely* important. Am I of the opinion that removing the function keyword from the class definition will help? Yes, I am. Do I think it's some incredible advancement? No, I don't. The key question for me is: does removing it hurt PHP in any way? And for me, the answer is a clear and resounding no. I do not grep code for method definitions: I know exactly where they are and so will my IDE if I happen to not be using vim. And for those who like to grep for method definitions they can keep the keyword present. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On 02/19/2013 03:45 PM, Levi Morrison wrote: The key question for me is: does removing it hurt PHP in any way? And for me, the answer is a clear and resounding no. I do not grep code for method definitions: I know exactly where they are and so will my IDE if I happen to not be using vim. And for those who like to grep for method definitions they can keep the keyword present. Except when I come along and try to grok your code. I rarely search my own code. From the very beginning of PHP we have always favoured readability over fewer keystrokes. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
I am something of a language guru and to me syntax is *extremely* important. Am I of the opinion that removing the function keyword from the class definition will help? Yes, I am. I'm missing the help. It saves 9 characters and creates a disjunction between global function syntax and function-as-method syntax? Sorry, I can't see this as anything better than neutral. And for those who like to grep for method definitions they can keep the keyword present. ... in their own code, not in all the code they are forced to maintain (whether that be newbie sloppy code or super-cool library code). -- S. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
The key question for me is: does removing it hurt PHP in any way? And for me, the answer is a clear and resounding no. I do not grep code for method definitions: I know exactly where they are and so will my IDE if I happen to not be using vim. And for those who like to grep for method definitions they can keep the keyword present. Except when I come along and try to grok your code. I rarely search my own code. Protip: use an IDE. No, I'm serious. I work from the command-line a lot. I grep, awk and sed a lot of things on a weekly (sometimes daily) basis. However, it does not replace a good IDE. Ever done a replace from the command line only to find out you messed up some binary files and/or git/svn information? Happens all the time when I don't use an IDE; good IDE's don't make that mistake. Let's stop pretending that the vast majority of PHP users actually grep source code looking for `function foo`. They don't. *They don't even know how to use grep.* However, every PHP developer has to write `function` and more importantly they have to read `function` over and over again. --- Does that mean that I think `function` ABSOLUTELY SHOULD BE made optional? No. I don't. Am I tired of everyone complaining about this particular issue and pointing to the fact that some external tool won't work if you remove the otherwise unnecessary keyword? Yes, I am. Take a step back and look at your argument guys: you may have strong personal feelings about it, but it's a pretty thin argument. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Protip: use an IDE. Linux is my IDE. -- Herman Radtke @hermanradtke | http://hermanradtke.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
Let's stop pretending that the vast majority of PHP users actually grep source code looking for `function foo`. They don't. *They don't even know how to use grep.* I don't grep as in `grep`, but as in regex search that is part of my IDE but is not also tokenizing/whateverizing/PHP-aware. My IDE lets me search for the declaration of a method by right-clicking class-method(), but it's only able to do that because it knows how to find the class definition and look there (and it doesn't use an autoloader). If I want to do a bulk search, it switches to regex, which doesn't share that intelligence. But I haven't upgraded to the v8 of this thing, only v7, so who knows... I find it indispensable and I'm not going to switch to another one because it isn't smart enough to do a PHP-aware bulk search. -- S. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Tue, 2013-02-19 at 17:08 -0700, Levi Morrison wrote: Let's stop pretending that the vast majority of PHP users actually grep source code looking for `function foo`. That was never said, but there's a big number of people who has to deal with code produced by others and doing tasks where it is not always appropriate to startup and IDE and create a project and index it and grep is not always a simple grep but some more complex operation involving a search. And as you are happy with your idea you can certainly create shortcuts so you can type puf or such instead of public function and maybe even to hide the function word. They don't. *They don't even know how to use grep.* However, every PHP developer has to write `function` and more importantly they have to read `function` over and over again. The ones who don't know about 'grep' are happy about the extra clue. Am I tired of everyone complaining about this particular issue and pointing to the fact that some external tool won't work if you remove the otherwise unnecessary keyword? Yes, I am. Take a step back and look at your argument guys: you may have strong personal feelings about it, but it's a pretty thin argument. The argument for removing (or rather: the argument for adding yet another alternate syntax) is even weaker. Code is more often read than written. Now let's focus on work. johannes (who will now ignore this thread - we're turning in circles) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc
On Feb 19, 2013, at 6:01 PM, Zeev Suraski z...@zend.com wrote: Are we really trying to look under ground now for ways to change the language syntax? Agree 100%. Not to mention, I plan on eventually convincing enough people to replace that keyword with a type hint ;) Unless there's a strong case to adding/removing/changing syntax, that goes well beyond 'because we can' or 'it shortens the code' it shouldn't even be brought up for discussion. Zeev On 19 בפבר 2013, at 19:44, Nikita Nefedov inefe...@gmail.com wrote: Hi! As someone mentioned in the thread about short syntax for closures, we could also drop requirement for `function` keyword when defining/declaring methods in classes, interfaces or traits. I have long noticed how redundant it is. The patch is pretty easy as it was with commas :) It is absolutely backwards compatible (you can use `function` or you can not use it). Here's the patch: https://gist.github.com/nikita2206/4988075 If people will welcome this proposal, I would need some karma for making RFC. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php