Re: [PHP-DEV] function call chaining

2010-01-20 Thread Ronald Chmara
Religious programming is the problem. On Tue, Jan 19, 2010 at 6:28 PM, Gwynne Raskind wrote: > On Jan 19, 2010, at 5:54 PM, Alain Williams wrote: $eep->oop()->ork()->ah()->ah(); the newcomer will have to spend significant time rummaging around the source code to figure out wha

Re: [PHP-DEV] function call chaining

2010-01-20 Thread Jani Taskinen
Instead of adding yet-another feature, how about fixing the bugs in the existing ones first? f.e. there is open bug related to closures, fixing that might be good idea before adding yet another way to abuse them: http://bugs.php.net/50230 And in total there are 33 scripting engine (includi

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Stan Vassilev
If everything is chained, it's a pain to figure out such basic workings. Hi, I still find it hard to understand why some should artificially claim basic constructs supported by other languages for years are somehow more complex than PHP's existing semantics. Supporting dereferencing in all

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Daniel Convissor
Hi Stas: On Tue, Jan 19, 2010 at 12:09:53PM -0800, Stanislav Malyshev wrote: > > $oop = $eep->oop(); > $ork = $oop->ork(); > $ah = $ork->ah(); > $ah2 = $ah->ah(); > > where it instantly becomes crystal clear! :) Yep, that's lousy code. Variables should be named for the classes they represent.

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Gwynne Raskind
On Jan 19, 2010, at 5:54 PM, Alain Williams wrote: >>> $eep->oop()->ork()->ah()->ah(); >>> >>> the newcomer will have to spend significant time rummaging around the >>> source code to figure out what classes are involved. >> As opposed to: >> $oop = $eep->oop(); >> $ork = $oop->ork(); >> $ah = $or

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Alain Williams
On Tue, Jan 19, 2010 at 12:09:53PM -0800, Stanislav Malyshev wrote: > Hi! > > >$eep->oop()->ork()->ah()->ah(); > > > >the newcomer will have to spend significant time rummaging around the > >source code to figure out what classes are involved. > > As opposed to: > $oop = $eep->oop(); > $ork = $oo

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Stanislav Malyshev
Hi! $eep->oop()->ork()->ah()->ah(); the newcomer will have to spend significant time rummaging around the source code to figure out what classes are involved. As opposed to: $oop = $eep->oop(); $ork = $oop->ork(); $ah = $ork->ah(); $ah2 = $ah->ah(); where it instantly becomes crystal clear!

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Daniel Convissor
Hi Stas: > If you don't understand the language, nothing is self-documenting. Yes. For clarity, what I meant by the "knowing the language" reference, I was imagining a PHP programmer trying to read/debug the code of a pre-existing project for the first time. When the code does stuff like: fo

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Stanislav Malyshev
Hi! Sure. But one needs to understand the language. Otherwise the reader needs to go hunting around a dictionary (or in our case, the source code) to figure out what the heck the person (code) is trying to say (do). Chaining produces code that is not self-documenting. If you don't understan

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Daniel Convissor
Hi Stas: On Tue, Jan 19, 2010 at 10:30:28AM -0800, Stanislav Malyshev wrote: > > People like to speak in full expressive sentences Sure. But one needs to understand the language. Otherwise the reader needs to go hunting around a dictionary (or in our case, the source code) to figure out what

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Stanislav Malyshev
Hi! enhancements in the sense that they enable things that were not possible before, sure. syntax sugar that hurts readability, not really. It starts to seem to me that the notion of readability is rather different here than in the rest of the world. Lately, almost any syntax sugar features

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Stanislav Malyshev
Hi! I don't mind the foo()() syntax, especially now that we have closures. But people are right, we have a longstanding feature request for $foo()[0] as well, so if we start down this path of adding chaining, we should do that one as well and see if any others make sense. As I said, that was n

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Richard Lynch
On Tue, January 19, 2010 5:19 am, Alain Williams wrote: > I have seen the argument that things like this will confuse novice > programmers, > maybe: but would they ever try to type something like that ? Yes, because they see the experts typing something like that. What's more, they have to READ s

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Richard Lynch
On Tue, January 19, 2010 1:29 am, Eddie Drapkin wrote: > On Tue, Jan 19, 2010 at 2:14 AM, Alexey Zakhlestin > wrote: >> >> Would be nice if something like this worked too: >> >>    (new Class())->method(); >> >> > > I was just looking at some Java code and thinking, "man I wish PHP did > this."

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Jochem Maas
Op 1/19/10 1:27 AM, Stanislav Malyshev schreef: > Hi! > > I wrote a small patch that enables this kind of syntax in PHP: > > foo()(); > > What it means is that if foo() returns callable value (which probably > should be function name or closure) then it would be called. Parameters > and more tha

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Lukas Kahwe Smith
On 19.01.2010, at 18:39, Rasmus Lerdorf wrote: > I don't mind the foo()() syntax, especially now that we have closures. > But people are right, we have a longstanding feature request for > $foo()[0] as well, so if we start down this path of adding chaining, we > should do that one as well and see

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Rasmus Lerdorf
Stanislav Malyshev wrote: > Hi! > > I wrote a small patch that enables this kind of syntax in PHP: > > foo()(); > > What it means is that if foo() returns callable value (which probably > should be function name or closure) then it would be called. Parameters > and more than two sets of () work

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Chris Stockton
Hello, On Tue, Jan 19, 2010 at 10:07 AM, Lukas Kahwe Smith wrote: > > On 19.01.2010, at 18:03, Chris Stockton wrote: > enhancements in the sense that they enable things that were not possible > before, sure. syntax sugar that hurts readability, not really. > if you are worried about key strokes

RE: [PHP-DEV] function call chaining

2010-01-19 Thread Jared Williams
> -Original Message- > From: Stanislav Malyshev [mailto:s...@zend.com] > Sent: 19 January 2010 00:28 > To: 'PHP Internals' > Subject: [PHP-DEV] function call chaining > > Hi! > > I wrote a small patch that enables this kind of syntax in PHP: > > foo()(); > > What it means is that if

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Lukas Kahwe Smith
On 19.01.2010, at 18:03, Chris Stockton wrote: > Hello, > > On Mon, Jan 18, 2010 at 5:27 PM, Stanislav Malyshev wrote: >> I wrote a small patch that enables this kind of syntax in PHP: >> >> foo()(); >> ... > > I think language enhancements with no BC breaks that offer a wider > toolset to pr

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Chris Stockton
Hello, On Mon, Jan 18, 2010 at 5:27 PM, Stanislav Malyshev wrote: > I wrote a small patch that enables this kind of syntax in PHP: > > foo()(); > ... I think language enhancements with no BC breaks that offer a wider toolset to programmers is a good thing. I would also like to see the other idea

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Pierre Joye
On Tue, Jan 19, 2010 at 5:00 PM, Stanislav Malyshev wrote: > Hi! > >> I'm not a fan of this kind of syntaxic sugars, especially for >> procedural implementation only. What are the benefits? > > Some as all other syntax sugars - better-looking code. Ah ok, then let say -1 from here for the functio

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Stanislav Malyshev
Hi! I'm not a fan of this kind of syntaxic sugars, especially for procedural implementation only. What are the benefits? Some as all other syntax sugars - better-looking code. -- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zend.com/ (408)253-8829 MSN: s...@zend.com

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Alain Williams
On Tue, Jan 19, 2010 at 01:55:32PM +0300, Alexey Zakhlestin wrote: > > On 19.01.2010, at 13:47, Christian Schneider wrote: > > > Alexey Zakhlestin wrote: > >> Would be nice if something like this worked too: > >>(new Class())->method(); > > > > If you *really* want to do this you can use a f

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Alexey Zakhlestin
On 19.01.2010, at 13:47, Christian Schneider wrote: > Alexey Zakhlestin wrote: >> Would be nice if something like this worked too: >>(new Class())->method(); > > If you *really* want to do this you can use a factory method: > Class::create()->method(); I know. That's what I do if I need it.

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Pierre Joye
hi Stan, On Tue, Jan 19, 2010 at 1:27 AM, Stanislav Malyshev wrote: > Hi! > > I wrote a small patch that enables this kind of syntax in PHP: > > foo()(); > > What it means is that if foo() returns callable value (which probably should > be function name or closure) then it would be called. Parame

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Christian Schneider
Alexey Zakhlestin wrote: > Would be nice if something like this worked too: > (new Class())->method(); If you *really* want to do this you can use a factory method: Class::create()->method(); - Chris -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Antony Dovgal
On 01/19/2010 01:30 PM, Jani Taskinen wrote: > Funny, I was just thinking the opposite "man I wish PHP never allows > this" :) > > Can of worms I say, can of worms.. Exactly my thought. Please, let's not open it. -- Wbr, Antony Dovgal --- http://pinba.org - realtime statistics for PHP -- PHP

Re: [PHP-DEV] function call chaining

2010-01-19 Thread Jani Taskinen
On 01/19/2010 09:29 AM, Eddie Drapkin wrote: On Tue, Jan 19, 2010 at 2:14 AM, Alexey Zakhlestin wrote: Would be nice if something like this worked too: (new Class())->method(); I was just looking at some Java code and thinking, "man I wish PHP did this" Funny, I was just thinking the

Re: [PHP-DEV] function call chaining

2010-01-18 Thread Eddie Drapkin
On Tue, Jan 19, 2010 at 2:14 AM, Alexey Zakhlestin wrote: > > Would be nice if something like this worked too: > >    (new Class())->method(); > > I was just looking at some Java code and thinking, "man I wish PHP did this." -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe,

Re: [PHP-DEV] function call chaining

2010-01-18 Thread Alexey Zakhlestin
On 19.01.2010, at 3:27, Stanislav Malyshev wrote: > Hi! > > I wrote a small patch that enables this kind of syntax in PHP: > > foo()(); > > What it means is that if foo() returns callable value (which probably should > be function name or closure) then it would be called. Parameters and more

Re: [PHP-DEV] function call chaining

2010-01-18 Thread Richard Lynch
On Mon, January 18, 2010 6:27 pm, Stanislav Malyshev wrote: > I wrote a small patch that enables this kind of syntax in PHP: > > foo()(); > > What it means is that if foo() returns callable value (which probably > should be function name or closure) then it would be called. > Parameters > and more