FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » The goto statement in PHP
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
The goto statement in PHP [message #185732] Mon, 05 May 2014 13:50 Go to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
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.
Re: The goto statement in PHP [message #185734 is a reply to message #185732] Mon, 05 May 2014 14:27 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
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.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
Re: The goto statement in PHP [message #185739 is a reply to message #185734] Mon, 05 May 2014 15:08 Go to previous messageGo to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
On Mon, 05 May 2014 10:27:36 -0400, Jerry Stuckle 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.

Yeah I know. I've heard it a zillion times before.
"Any language that uses a 'goto' is one that is screwed up".
But hey, there are times when the evil is required.

I recall a scene from a movie.
Dozens of federal agents armed to the teeth break into a hacker's
residence.
He's busy trying to erase all of his hard work so they have no evidence.
"No you got it wrong boy. We're not here to bust you. This time. We're to
hire you!".
Purely for the drama of course.
Re: The goto statement in PHP [message #185740 is a reply to message #185739] Mon, 05 May 2014 15:33 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/5/2014 11:08 AM, richard wrote:
> On Mon, 05 May 2014 10:27:36 -0400, Jerry Stuckle 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.
>
> Yeah I know. I've heard it a zillion times before.
> "Any language that uses a 'goto' is one that is screwed up".
> But hey, there are times when the evil is required.
>
> I recall a scene from a movie.
> Dozens of federal agents armed to the teeth break into a hacker's
> residence.
> He's busy trying to erase all of his hard work so they have no evidence.
> "No you got it wrong boy. We're not here to bust you. This time. We're to
> hire you!".
> Purely for the drama of course.
>

Nope, goto is NEVER "required". Sometimes it's handy, but never required.

Even in almost 30 years of C and C++ programming I have never *HAD* to
use goto. Proper code structure eliminates the need (and reduces the
number of potential errors).

Now that's not to say I've *NEVER* used goto. But the number of times
I've used it can be counted on one hand. And then it's because I'm
doing device drivers or similar, where size and speed are important
(still true on some ARM devices).

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
Re: The goto statement in PHP [message #185743 is a reply to message #185740] Mon, 05 May 2014 15:44 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <lk8avk$ivl$1(at)dont-email(dot)me>, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> On 5/5/2014 11:08 AM, richard wrote:
>> On Mon, 05 May 2014 10:27:36 -0400, Jerry Stuckle 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.
>>
>> Yeah I know. I've heard it a zillion times before.
>> "Any language that uses a 'goto' is one that is screwed up".
>> But hey, there are times when the evil is required.
>>
>> I recall a scene from a movie.
>> Dozens of federal agents armed to the teeth break into a hacker's
>> residence.
>> He's busy trying to erase all of his hard work so they have no evidence.
>> "No you got it wrong boy. We're not here to bust you. This time. We're to
>> hire you!".
>> Purely for the drama of course.
>
> Nope, goto is NEVER "required". Sometimes it's handy, but never required.

I was about to say that I hadn't used a goto since I stopped using
FORTRAN in 1978, but then I remembered that I had to use a flavour of
Pascal on a PDP-11 in 1982, and as that had no return statement, I had
to simulate one by putting a 999 label on the final 'end', and goto
that.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: The goto statement in PHP [message #185752 is a reply to message #185739] Tue, 06 May 2014 00:57 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
richard <noreply(at)example(dot)com> wrote in news:5a5ko3egtigm$.hpt5q76uozk1$.dlg@
40tude.net:

> Yeah I know. I've heard it a zillion times before.
> "Any language that uses a 'goto' is one that is screwed up".
> But hey, there are times when the evil is required.

Actually, no, it is not. It was mathematically proven some fifty years ago that GOTO is never
necessary. Google "Dykstra" for more information.
Re: The goto statement in PHP [message #185754 is a reply to message #185752] Tue, 06 May 2014 02:06 Go to previous messageGo to next message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma: 0
Member
On Tue, 6 May 2014 00:57:49 +0000 (UTC), Doug Miller
<doug_at_milmac_dot_com(at)example(dot)com> wrote:

> richard <noreply(at)example(dot)com> wrote in news:5a5ko3egtigm$.hpt5q76uozk1$.dlg@
> 40tude.net:
>
>> Yeah I know. I've heard it a zillion times before.
>> "Any language that uses a 'goto' is one that is screwed up".
>> But hey, there are times when the evil is required.
>
> Actually, no, it is not. It was mathematically proven some fifty years ago that GOTO is never
> necessary. Google "Dykstra" for more information.

That's "Dijkstra"
Re: The goto statement in PHP [message #185762 is a reply to message #185754] Tue, 06 May 2014 17:23 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
Richard Yates <richard(at)yatesguitar(dot)com> wrote in
news:jrggm95e7n4p9fo94l0qcisic6r0f3f5ja(at)4ax(dot)com:

> On Tue, 6 May 2014 00:57:49 +0000 (UTC), Doug Miller
> <doug_at_milmac_dot_com(at)example(dot)com> wrote:
>
>> richard <noreply(at)example(dot)com> wrote in
> news:5a5ko3egtigm$.hpt5q76uozk1$.dlg@
>> 40tude.net:
>>
>>> Yeah I know. I've heard it a zillion times before.
>>> "Any language that uses a 'goto' is one that is screwed up".
>>> But hey, there are times when the evil is required.
>>
>> Actually, no, it is not. It was mathematically proven some fifty years
> ago that GOTO is never
>> necessary. Google "Dykstra" for more information.
>
> That's "Dijkstra"
>
Yes, you're right of course. I knew better. I was in a hurry and didn't proofread.
Re: The goto statement in PHP [message #185765 is a reply to message #185732] Wed, 07 May 2014 02:02 Go to previous messageGo to next message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma: 0
Senior Member
On 05/05/2014 09: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.
>


$a is a VARIABLE

a: is a LABEL


How are they not distinguished from one another?

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Re: The goto statement in PHP [message #185772 is a reply to message #185734] Wed, 07 May 2014 15:13 Go to previous messageGo to next message
Graham Hobbs is currently offline  Graham Hobbs
Messages: 42
Registered: September 2010
Karma: 0
Member
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.
Graham Hobbs
Re: The goto statement in PHP [message #185776 is a reply to message #185772] Wed, 07 May 2014 19:07 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
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.
Re: The goto statement in PHP [message #185777 is a reply to message #185776] Wed, 07 May 2014 19:16 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <lke0a8$gcs$1(at)news(dot)albasani(dot)net>, The Natural Philosopher
<tnp(at)invalid(dot)invalid> wrote:

> 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.

Well, in assembler it'll just be a JMP or equivalent, won't 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 once worked with a FORTRAN compiler that gave exactly that message if
you put:

GOTO JAIL

> I've always felt Dijkstra was a bit of a Dijk...frankly.

Did he also try to insist on single-entry-single-exit for functions?
I've never paid any attention to that; early return for error
conditions is the way to do it.

--
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
Re: The goto statement in PHP [message #185785 is a reply to message #185732] Fri, 09 May 2014 08:30 Go to previous messageGo to next message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma: 0
Senior Member
Am 05.05.2014 15:50, schrieb richard:

> 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.

Of course they do

<http://www.php.net/manual/en/control-structures.goto.php>

Example on that page:


<?php
goto a;
echo 'Foo';

a:
echo 'Bar';
?>

And even you should remember, that variables in PHP start with "$", so
"a$" would be the variable and "a:" the label.



--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de
Re: The goto statement in PHP [message #185786 is a reply to message #185785] Fri, 09 May 2014 10:00 Go to previous message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma: 0
Senior Member
Am 09.05.2014 10:30, schrieb Arno Welzel:
> Am 05.05.2014 15:50, schrieb richard:
>
>> 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.
>
> Of course they do
>
> <http://www.php.net/manual/en/control-structures.goto.php>
>
> Example on that page:
>
>
> <?php
> goto a;
> echo 'Foo';
>
> a:
> echo 'Bar';
> ?>
>
> And even you should remember, that variables in PHP start with "$", so
> "a$" would be the variable and "a:" the label.

Uhh... typo... "$a" and "a:" of course ;-)


--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: part two same issue - unwanted empty values in array
Next Topic: richard
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 01 00:24:58 GMT 2024

Total time taken to generate the page: 0.04319 seconds