[Solved]: Why would you introduce the goto statement into a modern language?

Problem Detail: I just found out something really quite extraordinary. While looking through Stackoverflow, I came across a question about removing goto from a php function. PHP doesn’t have goto I thought and looked it up on php.net. It turns out I was sort of right. PHP introducted goto in version 5.3 which was release in 2009. PHP didn’t start out with gotoit actually introduced it into the language in 2009! Why on earth with all the horror stories we have from 40 years of bad programs written with goto in other languages would php actually decide to introduce it? The php.net website even has this XKCD image suggesting no programmer should ever use goto. enter image description here

Question:

What possible reason from a technical point of view could there be for introducing a the goto feature, which I nievely thought had been vanquished from modern computer programming languages?

Asked By : Toby Allen

Answered By : gnasher729

There are two kinds of programmers: Those who for whatever reason never, ever use goto, and go to any lengths to avoid it, and those who use goto in one of the very rare situations where it is the best solution. (Someone said here in a comment that goto could be misused and programmers would find ways to misuse it – but those people are not programmers). It makes sense to add “goto” to a language that doesn’t have it if there is evidence that there are situations where it improves the code, and if it is not too difficult to implement. So I would assume that there was such evidence.
Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/48050  Ask a Question  Download Related Notes/Documents