Re: Re: Generators in PHP

From: Date: Tue, 24 Jul 2012 19:16:24 +0000
Subject: Re: Re: Generators in PHP
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 24/07/12 20:13, Alex Aulbach wrote:
2012/7/24 Gustavo Lopes <[email protected]>:
When you have function foo() { ... yield /* ... */; ... } and you call foo(), you get the same thing every time: a Generator object. It so happens that the implementation of that object is inside the body of the function.
Hmmm. It's not that I didn't understand it. :) My thoughts are about usage in practice. Ok, my first argument with the developer, who overtakes an old project was weak. What about situations, when developers with different knowlegde work together? Or when you have programming errors, when you write function blubb() { ... yields... ... ... return.... } (you may only see the "return"). And many those situations are thinkable, because this kind of PHP function works so totally different from current.
Maybe this helps you reason about the feature.
Please understand me, it's not that I don't like it or that I couldn't live with it. It's because I have too much experience what could happen if new programming features are introduced. For example: Exceptions in PHP are quite old now. And the concept of exceptions should be known. But I worked together with programmers wich produced code like ... try {
      $value = method_which_throws_exceptions();
} catch (...) {
      return $value;
} return $value; ... And he has it done, although I wrote some example code for him how to use exceptions in this context!!11! THAT'S the reality. We can ignore that, but I just want to make such simple mistakes not so easy and the afford is worth the results. You can argue: "Those mistakes will always happen". I say "Yes, of course, but if we have the chance to reduce those mistakes we should do it." It's fairly obvious from context these aren't ordinary functions, IMO.
And anyway, what could possibly go wrong? Is there any incorrect but non-fatal or warning-generating way you could use them? -- Andrew Faulds http://ajf.me/

Thread (142 messages)

« previous php.internals (#61725) next »