Re: The goto statement in PHP [message #185776 is a reply to message #185772] |
Wed, 07 May 2014 19:07 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 07/05/14 16:13, Graham Hobbs wrote:
> On Mon, 05 May 2014 10:27:36 -0400, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 5/5/2014 9:50 AM, richard wrote:
>>> In Liberty BASIC (LB) we also have branched goto labels.
>>> As I was reading the goto manual on php.net I see where they make no
>>> distinction between a label and a variable.
>>> In LB it is simple.
>>> a=0 is a distinct variable.
>>> [a] is a distinct label.
>>>
>>> When goto [a] is encountered, it matters not what or where the variable "a"
>>> is.
>>>
>>> I'm just suggesting that they need a means to distinguish the pair.
>>>
>>
>> Better yet - don't use goto. I never have needed it.
> Just reminds me of the 'sphagetti' code' days.
I have never NEEDED it above assembler code, it but I have occasionally
USED it.
I think its possible to say that its almost impossible to get away
without it at assembler level.
If I had a chip that didn't do it I'd probably do a subroutine call and
pop the stack pointer ;-)
In high level languages like PHP the curly brace, break, return and
continue are all goto statements. In that they break program flow in
defined ways unconditionally.
sometimes its syntatically cleaner to use a goto to break out of deep
nesting to a cleanup and exit routine than reverse out of all those
nested levels.
As with all things its not the tools fault, its how and when you use it.
Sometimes 'Go To jail: go directly to jail, do not pass Go, do not
collect £200' is exactly the simplest way to express something.
I've always felt Dijkstra was a bit of a Dijk...frankly.
> Graham Hobbs
>
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|