On 25/07/12 17:54, Alex Aulbach wrote:
2012/7/25 Andrew Faulds <a...@ajf.me>:
Experience can be helpful. But you must support things with facts
Ok, I tried to bring all the pro arguments together.

Suggestion:

For a generator, rename the keyword "function" to ... "generator" or
something like that. Example:
    generator hugo()
    {
      yield ...
    }

Fact: yield/generators is more or less complicated, this shouldn't be
changed - it's a proven concept.
Fact: yield makes functions some kind of "different".
Fact: It doesn't matter how much difference and if PHP has already
"different" behaving functions. We're talking about now.
Fact: It doesn't matter how it is implemented in other languages,
because we talk about PHP and not other languages.
Fact: This is also good style in general: Call the things what they are.
Fact: as PHP-developer we must try to avoid making things more
complicated, because this is one of the best features of PHP.
Fact: it's easy to implement a new keyword  into PHP for that case

Experience: Most PHP programmers will have problems to understand
generators because it is a function that generates an iterator...
something magic <eyesroll> they never heard of before.
Experience: generators/yield can't be explained on one page. Much
programmers will never ever read so much docs. :)
Experience: good features are self-explaining. A function which
returns an iterator because of a simple word in it's body is not.
Experience: They will make stupid mistakes, because they mix yield
function with normal functions.
Experience: They will make stupid mistakes, because they will look for
"return" instead for "yield".
Experience: again, yield is more or less complicated, it's in this
case not a good idea to cover complexity by using already existing
language constructs.
Experience: Not using the same name will remove a little bit pressure
from "busy" programmers
Experience: It's of course their fault, if the don't learn how to use
something. But this is against the concepts of PHP. This means: If we
have the chance to make things easier we must do it.
Experience: The current concept dosn't "feel right" for me. I like to
listen to my belly in those questions, because he is in most cases
right. With the change I suggested he stops grumbling.

Please correct me if I use arguments I thought they have been
generally agreed/some of them are new.

-
Alex Aulbach

Fact: Adding a new name for a special kind of function as a syntax construct is going to cost (possibly unnecessary) time and energy, because now you have functions, and weird things that look almost like functions but aren't and can only be used to make generators.

--
Andrew Faulds
http://ajf.me/


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to