Re: Re: Labeled Breaks (not the G-word)
| From: | Zeev Suraski | Date: | Sun, 27 Nov 2005 12:54:21 +0000 |
| Subject: | Re: Re: Labeled Breaks (not the G-word) | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20648@lists.php.net to get a copy of this message | ||
Guys,
Laughter has nothing to do with it.
However, as discussed between those who attended the meeting in Paris, goto earned its bad connotations for a reason. It was agreed that providing a general-purpose C-goto equivalent is not a good idea because it *will* very quickly lead to spaghetti coding styles. We also came to the conclusion that the main use case that is not covered by PHP today is that of 'centralized' error recovery, which requires forward jumping only (if it wasn't for that use case, I think we would have had consensus not to add any type of goto at all).
So, the logical conclusion appeared to be:
1. A forward-jumping construct only, to avoid giving users too much ammo to shoot themselves in the foot with spaghetti coding.
2. A construct which is not named 'goto', not because of the bad connotations (that's actually a good reason to keep it named 'goto'), but in order to make it clear that it's not goto, so that nobody expects it to behave like goto in other languages.
I'm not sold on reusing the break construct for that, since we're not really breaking, and I kind of like Ilia's "jump" idea. Another possibility would be reusing 'continue', which makes a bit more English sense, even though it's not very similar to continue's semantics.
Zeev
At 21:42 24/11/2005, Marcus Boerger wrote:
Hello Wez, i already see the whole world laughing at us :-) marcus Thursday, November 24, 2005, 5:43:48 PM, you wrote: Agreed; I see no reason to call it break (that makes it even more confusing), and limiting jumps to one direction only is dumb; there is no technical reason to do that. Perl has a "goto" keyword, but it's pronounced "magic goto". We can have a "goto" keyword and pronounce it "limited goto". Bad feelings and anticipated misuse are not good enough reasons to make this feature obscure. So, I'm +1 on the patch with sane names and removed restrictions; Thanks Sara and Dmitry :) --Wez. On 11/24/05, Edin Kadribasic <edink@emini.dk> wrote:to jump all overIlia Alshanetsky wrote:Derick Rethans wrote:- we wanted to prevent spagetti code which you can do by jumping up:"Similarly restricting the construct so that you can only jump down should satisfy people who do not want the abilityBest regards, MarcusIMO making this limitation puts a serious cramp of the functionality and the limiter should be removed.the place."I agree, I see no need for this limit. Edin