Re: GOTO operator

From: Date: Fri, 30 Jul 2004 00:00:17 +0000
Subject: Re: GOTO operator
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-11622@lists.php.net to get a copy of this message
Ilia Alshanetsky wrote:
PHP is a not a type strict language, far from it and it is unlikely it'll ever be such. It is also a not pure OOP language and I very much doubt it'll ever be one. While GOTO can be abused, so can any other language feature, such as OOP, or the ability to include remote files. If we add this feature certain warnings should made about it using it (as with almost any feature), but I see no reason to cripple advanced users simply other users may find fun and usual ways to abuse this useful functionality. Anyone who has ever written a parser will tell you GOTO is absolutely essential unless you want to go into recursive functions etc... which are way slower. GOTO also provides a fast an safe alternative to many solution where so far the only viable option (for most people) have been a recursive functions and those tend to smash the stack once in a while. Is the average Joe going to write parsers in the everydays work? Probably not.
But give him the power of goto and (s)he is going to shoot him/her in the legs, in the heart, in the head. And even not only himself because (s)he will create a legacy code which someone else has to understand and fix. We have extract() and we say in the docs it is not good to use it to populate variables but people hack and workaround register_globals set to off by just using this function. IMO PHP has enough power even without "goto". Left aside what Dijkstra has written. goto code tends to become spaghetti one. Sometimes I miss it when write PHP scripts (for example jumping between 2 clauses in a switch, something which is used in var_dump() C implementation) but then I reconsider that it is better this way. Looks like I am -1 if that counts :) thanks, andrey

« previous php.internals (#11622) next »