# Generators in PHP

- Thread: https://externals.io/message/61796
- Original archive: https://news-web.php.net/php.internals/61796
- Started by Yahav Gindi Bar on 2012-07-25T22:31:47+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #61796 — Yahav Gindi Bar — 2012-07-25T22:31:47+00:00

URL: https://externals.io/message/61796#61796

> 2012/7/25 Nikita Popov <nikita.ppv@gmail.com>:
> > […]
> 
> Hm. Ok, thats a problem.
> Oh, man, do I really have to find a good keyword myself? Maybe we
> should use a password-generator. :)
> Seriously, how's about
> 
>         yielder hugo() { ... yield ...}
> 
> Feels right, but my native language is not english, so I risk to make
> me a fool. I think that also names what it really is: A yielder yields
> something. In this case: An iterator yielder yields an iteration. I
> think I would like that.
> And the word is per sure not common. :)
> Ahmm, if you don't like it, would you be so kind to make a suggestion? TNX
> 
> > […]
> 
> In general I agree. For PHP I do not. This case is a little bit
> different, because the targets are self-explaining and simplicity.
> 
> > […]
> 
> But I gave good other reasons. :)
> 
> 
> 
> Conclusion:
> ==========
> 
> Fact: generator is not a good keyword, because too common.
> 
> Answer: I made a new sugestion with the keyword "yielder".
> 
> Fact: in general it's a good idea to implement features, like in other
> languages.
> 
> A: Correct, but
> 
> Fact: PHP has different architectural targets which doesn't mean to
> make everything different, but ...
> Experience: in this case I'm sure, it's not the best way to make it
> like any other language.
> Experience: If you have enough reasons to make things different, don't
> look too much how others are doing.
> Experience: Most PHP-programmers are not so experienced like most
> programmers in other languages.
> (Can't be proven, but I would bet for it.)
> 
> -- 
> Alex Aulbach
> 
> -- 
> 
> 
> 

Wow, I wasn't near my computer for the last day and I see that the conversation really grew ;)
"yielder" sounds quite weird don't you think (but my native language is not English too.. so don't blame me at english stupid conclusions!)

> Fact: generator is not a good keyword, because too common.
I can't see the connection... people relate the generator keyword to the iterators so what's the problem using it?

what about using the "iterator" name as generators keyword? because it does return iterators...

iterator foo() { ... yield $bar; ... } sounds OK for me... and got a meaning too.
though it can confuse some people with the original iterators...

BTW: I still don't think that the generators need a unique word and I suggest using functions, but I didn't read al the mails chain, so I assume that I'll find there the answer.
