Re: Re: Generators in PHP

From: Date: Tue, 24 Jul 2012 18:04:41 +0000
Subject: Re: Re: Generators in PHP
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-61713@lists.php.net to get a copy of this message
On 24/07/12 18:56, Alex Aulbach wrote:
2012/7/24 Andrew Faulds <ajf@ajf.me>:
Much easier to make an iterator with a function than as a class.
2012/7/24 Yahav Gindi Bar <g.b.yahav@gmail.com>:
I agree, implementing a class only for iterator may be pain sometimes, and functions is much better - especially when 5.3 got the anonymous functions, so we can even use the generators for iterator functions in class methods which can be great.
Ok, why not call it "iterator" or "generator" or "huffpuff" instead of "function"? It's just the naming, which disturbs me, because a function is something which is, when called once finished once. I don't like mathematics, but that is one of the definition of a function: http://en.wikipedia.org/wiki/Function_%28mathematics%29 "each input is related to exactly one output" Couldn't be so complicated to introduce a new name for that, or? You'll love LISP, I'm sure, or maybe Python's functional subset.
But PHP functions usually have side-effects, they aren't strict mathematical functions. So complaining about this is rather pointless. -- Andrew Faulds http://ajf.me/

« previous php.internals (#61713) next »