473,748 Members | 3,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why doesn't JavaScript have a goto command?

Perl has it, Basic has it, Fortran has it. What is so difficult about
creating a goto command for JavaScript. Just set up a label and say go
to it.

Mar 7 '06 #1
34 26644

el*********@ele ctrician.com wrote:
Perl has it, Basic has it, Fortran has it. What is so difficult about
creating a goto command for JavaScript. Just set up a label and say go
to it.


Javascript does indeed have a "goto" keyword but is just a reserved
keyword.

It is not the matter of difficulty of implementation but rather the use
of "goto" statements that generally leans towards spaghetti code. And
yes, it can also be argued that very conservative use of the statement
can be helpful at times.

Here's a very classic article:

title: Go To Statement Considered Harmful
url: http://www.acm.org/classics/oct95/

Mar 7 '06 #2
el*********@ele ctrician.com wrote:
Perl has it, Basic has it, Fortran has it. What is so difficult about
creating a goto command for JavaScript. Just set up a label and say
go to it.


There is no logcal need for goto.

The lack of goto forces you to think of the correct way to solve your
problem, rather than relying on spaghetti code :)

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Mar 7 '06 #3

<el*********@el ectrician.com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .
Perl has it, Basic has it, Fortran has it. What is so difficult about
creating a goto command for JavaScript. Just set up a label and say go
to it.


Because, if you need to use a GOTO, then you are doing something wrong.
Mar 7 '06 #4
Noozer wrote:
<el*********@el ectrician.com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .
Perl has it, Basic has it, Fortran has it. What is so difficult about
creating a goto command for JavaScript. Just set up a label and say go
to it.


Because, if you need to use a GOTO, then you are doing something wrong.


Not at all, sometimes you have to get out of two loops and with a goto
you can achieve this easily, goto is a reserved word, but JavaScript
has labels.

while(confirm(" ok?"))
MyLabel:
while(1)
while(1)
break MyLabel;
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com

Mar 7 '06 #5
Noozer wrote:
<el*********@el ectrician.com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .
Perl has it, Basic has it, Fortran has it. What is so difficult about
creating a goto command for JavaScript. Just set up a label and say go
to it.

Because, if you need to use a GOTO, then you are doing something wrong.


Ever program in Assembly?
Mar 7 '06 #6
<There is no logcal need for goto.

The lack of goto forces you to think of the correct way to solve your
problem, rather than relying on spaghetti code :)


So what about those of us that like programming in spaghetti code? Who
are you or the creators of JavaScript to force me to use their
programming concepts? I like Goto and want it and have worked for
hours to try something else when goto would have saved me precious
time. This is another example of academia forcing us to use useless
non productive time to preserve some higher than thou intellectual crap.

Mar 8 '06 #7
Zif
el*********@ele ctrician.com wrote:
<There is no logcal need for goto.

The lack of goto forces you to think of the correct way to solve your
problem, rather than relying on spaghetti code :)
So what about those of us that like programming in spaghetti code? Who
are you or the creators of JavaScript to force me to use their
programming concepts?
Someone has a gun at your head, forcing you to use JavaScript? Heck, you
must be one gun programmer.

You can't even be bothered to publish web pages that accommodate
browsers other than IE, why should anyone care about your opinion?

I like Goto and want it and have worked for
hours to try something else when goto would have saved me precious
time. This is another example of academia forcing us to use useless
non productive time to preserve some higher than thou intellectual crap.


But you'd like to force them to implement goto because you want them
too? Because it fits with your concept of programming learned where?
What substantive argument can you provide to show that goto is of any
benefit to JavaScript?

Your 'calculator'[1] stands as a public record of your programming
ability. Claiming ignorance of standards and design principles as a
virtue does not make it so. Did you fix the errors that were pointed
out to you?
1.
<URL:http://groups.google.c o.uk/group/comp.lang.javas cript/browse_frm/thread/3b545c991e656da 6/4355f865f033ecb e?q=How+do+you+ stop+a+javascri pt+program%3F&r num=1#4355f865f 033ecbe>

--
Zif
Mar 8 '06 #8
Jonas Raoni wrote:
Noozer wrote:
<el*********@ electrician.com > wrote in message
news:11****** *************** *@i39g2000cwa.g ooglegroups.com ...

Perl has it, Basic has it, Fortran has it. What is so difficult about
creating a goto command for JavaScript. Just set up a label and say go
to it.


Because, if you need to use a GOTO, then you are doing something wrong.

Not at all, sometimes you have to get out of two loops and with a goto
you can achieve this easily, goto is a reserved word, but JavaScript
has labels.

while(confirm(" ok?"))
MyLabel:
while(1)
while(1)
break MyLabel;

That is not the typical use of goto. A better pseudo-code example would be:

while (...){
if (...) {
goto foo;
} else if (...) {
goto bar;
}
}

foo: { }
bar: { }

But you can achieve the same result without using goto.

goto is long dead. If you want to support it's revival, present a
scenario where it is required, or where it is significantly more
efficient than existing methods.
--
Rob
Mar 8 '06 #9
RobG wrote:
Jonas Raoni wrote:
That is not the typical use of goto. A better pseudo-code example would
be:

while (...){
if (...) {
goto foo;
} else if (...) {
goto bar;
}
}

foo: { }
bar: { }
Sure, this is a better example of a goto, but JavaScript has not the
goto statement:

alert(goto = 1);

There's just the label, which is similar to a goto, but just works
together with break and continue.
But you can achieve the same result without using goto.
Sure :)
goto is long dead. If you want to support it's revival, present a
scenario where it is required, or where it is significantly more
efficient than existing methods.


One day you'll need to exit from a two nested loop, in this day you'll
see that a label is useful for something.

I've used the label something around two times, sure I could avoid it,
but it would require extra checking in the inner loop, in this specific
situation I'm all for the labels ;]
--
Now with alcohol <URL:http://youtube.com/watch?v=lnQTZxq xc10> =X
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Mar 8 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
13383
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this wrong????? Function x select case z
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.