Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11734 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83956 invoked by uid 1010); 30 Jul 2004 21:08:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 83678 invoked from network); 30 Jul 2004 21:08:43 -0000 Received: from unknown (HELO dns1.systems.townnews.com) (208.229.121.1) by pb1.pair.com with SMTP; 30 Jul 2004 21:08:43 -0000 Received: from [10.81.10.35] (leepcK-165.sub-k.lee.net [12.163.62.165]) (authenticated bits=0) by dns1.systems.townnews.com (8.12.11/8.12.11) with ESMTP id i6UL8oba011403 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Fri, 30 Jul 2004 16:08:51 -0500 Message-ID: <410AB8D6.6010302@townnews.com> Date: Fri, 30 Jul 2004 16:08:38 -0500 User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeff Moore CC: Paul G , internals@lists.php.net References: <20040729021337.73894.qmail@pb1.pair.com> <200407291117.09573.lpedretti@suserver.com> <200407291037.12396.ilia@prohost.org> <41098F91.3000606@hristov.com> <004801c475bd$812f3580$0200a8c0@rusko> <410A5CBC.9090500@townnews.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] GOTO operator From: sthomas@townnews.com (Shaun Thomas) Jeff Moore wrote: > function pseudocode() { > try { > $a = allocate_resource_z(); > $b = allocate_resource_y(); > $res = do_stuff(); > $c = allocate_resource_x(); > $res = do_more_stuff(); > $d = allocate_resource_foo(); > $res = do_even_more_stuff(); > } catch ( Exception $e ) { > free_resouce($a); > free_resouce($b); > if(isset($c)) free_resouce($c); > if(isset($d)) free_resouce($c); > throw ($e); > } > } > > Where did the if statements go? do_stuff(), do_more_stuff(), and > do_even_more_stuff() should throw exceptions rather than return boolean > error indicators. True, which is really just a more revised version of the point that's been being passed around in one form or another. I was assuming the functions called didn't necessarily throw errors, like a PHP internal or similar, where you'd want to check the return code - but for an application coded around try/catch/throw, this would work perfectly. Personally, I'm used to the PEAR_Error, and PEAR::isError() method of error handling, so having the luxury of try/catch/throw in PHP 5 is a major improvement. But I guess the point is that having goto isn't really essential, as the original example tried to imply. But Ilia and Rasmus are also correct in that it wouldn't really hurt anything to add goto functionality, either. Most would ignore it, and it can only scope locally, so there's little chance of spaghetti. Sure, it's gross in general, but PHP isn't Python: enforcing coding style isn't PHP's thing. And as others have pointed out, we can all cite code that looks nasty, regardless of the presence of goto. For anyone who's ever seen Python code that *only* follows the indentation requirement, it does little to improve overall quality of the end product. Bad programmers will always find ways around language constructs, intentionally or otherwise. I'm just waiting for a language that imposes Javadoc style commenting in a 40% or greater ratio of comments to code, consistent indentation, brace style, and so on, just to see how it gets circumvented. Which is why I find it amusing PHP enforces camel-caps for class method names; that simply encourages bad programmers to use all lower case to avoid the issue entirely. -- Shaun M. Thomas INN Database Administrator Phone: (309) 743-0812 Fax : (309) 743-0830 Email: sthomas@townnews.com Web : www.townnews.com