I'm with Josh on this! There is no need for GOTO - this is a step back for PHPjosh wrote:Would much rather have [proper] lambda. And Jab, no. I would rather use objects to control my execution thru compositionI'm sure some people would rather use the goto too.
The sky is falling, the sky is falling!!
Moderator: General Moderators
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: The sky is falling, the sky is falling!!
Re: The sky is falling, the sky is falling!!
There is absolutely no need for Multithreading in PHP.
Re: The sky is falling, the sky is falling!!
GOTO, like guns, are tools to be used by the user. They can be used for good, or for bad. For example, I think this is a valid use of this GOTO
It doesn't jump around the code, is easy to follow, and is more efficient than you could do without the goto. PHP 5.3 is giving us more power, we just need to accept the responsibility to use it properly.
Code: Select all
$myArray = array(1,3,2,58,47,19);
$sum = 0;
$count = 0;
foreach($myArray as $number)
{
if($number < 20)
{
$sum += $number;
$count ++;
if($sum > 15)
goto found:
}
}
found:
echo $number.'<br />';
echo $count.'<br />';Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: The sky is falling, the sky is falling!!
That is not true! It depends on the project. Multi-threading can be a huge benefit in many places, especially when dealing with large applications and data sets.Jenk wrote:There is absolutely no need for Multithreading in PHP.
Re: The sky is falling, the sky is falling!!
pickle, you can use 'break' to achieve the same effects. I agree with you about the GOTO sentiments though
Re: The sky is falling, the sky is falling!!
It depends on what you're writing, what could be of use to some may not be to others, the only practical use for goto I can see so far is for your designer to use to jump to an HTML block within a phtml file or something, even then there are better ways of doing it. Too bad you can't do
$goto = 'foo';
goto $goto;
foo:
echo 'works';
exit();
I assume this doesn't work but I'm not at a terminal with PHP 5.3
$goto = 'foo';
goto $goto;
foo:
echo 'works';
exit();
I assume this doesn't work but I'm not at a terminal with PHP 5.3
Re: The sky is falling, the sky is falling!!
There is no 'they' in the true sense, PHP is an open source project, you could always implement these features yourself and submit a patch to the project.jaoudestudios wrote:I'm with Josh on this! There is no need for GOTO - this is a step back for PHPWhy dont they spend their time doing more important features. i.e multi-threading, daemonisation etc...
Personally I think goto can be useful for getting out of deeply nested loops but, like some other language constructs, used heavily can lead to code which could be difficult to read/follow.
If you don't like it don't use it, your scripts are not suddenly going to start failing because your not using goto. I can't imagine the inclusion of goto adds any real noticeable overhead to the interpreter so, if you don't need or want it does it really matter if it's available or not?
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: The sky is falling, the sky is falling!!
True, but when collaborating with other developers on a project, if it is there and can be an easier route (not necessarily the best), there is a huge possibility that it will get used and abused - thats my only concern!redmonkey wrote:if you don't need or want it does it really matter if it's available or not?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: The sky is falling, the sky is falling!!
It is not a step back because they have not removed any features.jaoudestudios wrote:I'm with Josh on this! There is no need for GOTO - this is a step back for PHP
I think this has been discussed many times, but there are a class of problems, parsers are the common example given, where using goto products cleaner, clearer code. You can go back to the inventors of the structured programming constructs to see that even they understood that they were not the best solution for all programming problems. Nothing is perfect.
And for those who are not clear, the new PHP goto is really a break-to-label and not a pure goto. So you can only goto out of loops, not into them, etc.
(#10850)
Re: The sky is falling, the sky is falling!!
Actually goto is usefull in other languages if you need to exit from a nested loop, for example:
But in PHP you have break $x to exit from nested loops
Code: Select all
while ($something)
while($someother)
if ($somecondition) goto end;
end:- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: The sky is falling, the sky is falling!!
But goto label is less error prone than break n. If you add/remove a nesting level the goto label still works, but you can forget to update the break n.Darhazer wrote:But in PHP you have break $x to exit from nested loops
(#10850)
Re: The sky is falling, the sky is falling!!
But surely you could do this instead:
Goto would use less code...but still, it's not necessary.
Code: Select all
$break = false;
while ($something && $break !== true)
while($someother && $break !== true)
if ($somecondition) $break = true;
Re: The sky is falling, the sky is falling!!
What about recoding this:jackpf wrote:But surely you could do this instead:
Goto would use less code...but still, it's not necessary.Code: Select all
$break = false; while ($something && $break !== true) while($someother && $break !== true) if ($somecondition) $break = true;
Code: Select all
while ($something)
{
while($someother)
{
process($someother);
if ($somecondition) goto end;
process2($someother);
}
process3($something);
}
end:There are 10 types of people in this world, those who understand binary and those who don't
Re: The sky is falling, the sky is falling!!
Any project that involves more than one developer should have a coding standard.jaoudestudios wrote:True, but when collaborating with other developers on a project, if it is there and can be an easier route (not necessarily the best), there is a huge possibility that it will get used and abused - thats my only concern!redmonkey wrote:if you don't need or want it does it really matter if it's available or not?
Re: The sky is falling, the sky is falling!!
VladSun wrote:What about recoding this:jackpf wrote:But surely you could do this instead:
Goto would use less code...but still, it's not necessary.Code: Select all
$break = false; while ($something && $break !== true) while($someother && $break !== true) if ($somecondition) $break = true;Code: Select all
while ($something) { while($someother) { process($someother); if ($somecondition) goto end; process2($someother); } process3($something); } end:
Code: Select all
$break = false;
while ($something && $break !== true)
{
while($someother && $break !== true)
{
process($someother);
if ($somecondition){$break = true; break;}
process2($someother);
}
if($break !== true)
process3($something);
}