At 04:55 PM 7/29/2004 -0700, Sara Golemon wrote:
Ack! Gods no.... Andi is already winding up to rip me a new one for
prematurely committing the patch earlier today, don't push him over the edge
by suggesting das uberevil ini options, even in jest! ;)

-Sara

P.S. - Andi: Ya know I love ya more than my luggage... :)

Just got home from OSCON and about to go to sleep.
Sara: I have gotten over my initial heart attack from this morning so don't worry about it :)


Let's for a second skip discussion of the patch itself, because although it was an interesting exercise the patch is not production ready.
However, I think before talking about implementation, we need to decide if goto is really good for PHP.
We talked about it quite a bit at OSCON, and I must say that I personally think that adding goto to PHP will do more harm than good.
It is true that for some advanced programmers, goto can come in handy, but the fact of the matter is that the PHP community has always taken a lot of pride in providing a language which keeps away from these kind of shortcuts.


I think there are only two cases where goto is really interesting:
a) Error handling.
b) Auto-generating code or compiler compilers (Sterling mentioned these two).

I think that the cases where you need it for error handling in PHP code aren't that great. Especially as the do..while(0) mechanism is much more useful in PHP than in other languages due to the ability to do "break n;". This ability in my opinion, is a good argument for why it's not as relevant in PHP as in other languages. And unlike someone mentioned in this thread, it is actually pretty fast and also takes care of all of the ugly stuff such as memory leaks from opcodes (not that it couldn't be implemented for goto but I'm just giving some more info and why it's a good thing).

I think that although slightly harder, code generators can probably also use similar constructs and survive without goto. I wouldn't want to add such a construct just for code generation. Sterling suggested calling the language construct something like "goto_only_use_for_autogenerated_code" (you get the point). His reasoning was that he doesn't really think it's needed by the average developer but it would be useful for automated tools. Not something I can completely disagree with but I think the downside outweighs the benefits.

I think that one can always find examples of how goto is useful, but it's hard to think ahead of time of how badly it will be abused. From my experience, although not quite as clear, it'll definitely be used in spaghetti code and will overall encourage bad coding practices, especially for less advanced programmers than people on this list.
Yes, any programmer can shoot himself in the foot with other PHP features, but we do have a responsibility to minimize that. One example is our introduction of E_STRICT. We don't warn about enough things but we do try. Why give our developers yet another way of shooting themselves in the foot? Or should I say, blow off their leg? :)


Andi

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



Reply via email to