Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11652 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79446 invoked by uid 1010); 30 Jul 2004 06:43:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 79277 invoked from network); 30 Jul 2004 06:43:25 -0000 Received: from unknown (HELO mail.zend.com) (80.74.107.235) by pb1.pair.com with SMTP; 30 Jul 2004 06:43:25 -0000 Received: (qmail 29549 invoked from network); 30 Jul 2004 06:43:23 -0000 Received: from localhost (HELO AndiNotebook.zend.com) (127.0.0.1) by localhost with SMTP; 30 Jul 2004 06:43:23 -0000 Message-ID: <5.1.0.14.2.20040729232459.02f31418@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Thu, 29 Jul 2004 23:43:13 -0700 To: "Sara Golemon" ,internals@lists.php.net In-Reply-To: <20040729235555.37129.qmail@pb1.pair.com> References: <20040729021337.73894.qmail@pb1.pair.com> <1091136355.490.4.camel@localhost> <1091139076.29517.12.camel@blobule.suds> <410991E1.6070000@hristov.com> <1091140927.29516.18.camel@blobule.suds> <41099925.4020700@hristov.com> <20040729225322.94418.qmail@pb1.pair.com> <41099C4A.4080206@hristov.com> <75910961.20040729190842@ionzoft.com> <41099EB2.9090403@hristov.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] GOTO operator From: andi@zend.com (Andi Gutmans) 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