Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #9677
| Message-ID | <1931071.aqSPkdTlGX@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2011-12-27 18:27 +0100 |
| Subject | Re: Simulate goto |
| Newsgroups | comp.lang.javascript |
| References | <ef9039a7-0cf7-4887-a98e-81c49968555b@p42g2000vbt.googlegroups.com> <4ef9a823$0$6842$e4fe514c@news2.news.xs4all.nl> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
Tom de Neef wrote:
> "Archos" <raul.san@sent.com> schreef […]
>> I'm trying to simulate the goto statement but I get an error
>>
>> ===
>> function testGoto() {
>> var isFirst = true;
>>
>> skipPoint:
>> alert("Using goto\n");
>>
>> if (isFirst) {
>> isFirst = false;
>> continue skipPoint;
>> alert("This part is skipped");
>> }
>> }
>> ===
>>
>> SyntaxError: label not found
>> continue skipPoint;
>
> The error may have more to do with 'continue' than with the label.
> Check where you can use a continue statement - I think it is restricted to
> for- and while- loops.
You are mistaken. The `continue' statement, like the Labelled Statement is
just another /Statement/, and it can be located anywhere in a /Program/:
,-[ES 5.1]
|
| 14 Program
|
| Syntax
|
| Program :
| SourceElements_opt
|
| SourceElements :
| SourceElement
| SourceElements SourceElement
|
| SourceElement :
| Statement
| FunctionDeclaration
,-[ibid.]
|
| 12 Statements
|
| Syntax
|
| Statement :
| Block
| VariableStatement
| EmptyStatement
| ExpressionStatement
| IfStatement
| IterationStatement
| ContinueStatement
| […]
| LabelledStatement
| […]
|
| 12.3 Empty Statement
|
| Syntax
| EmptyStatement :
| ;
|
| […]
| 12.7 The continue Statement
|
| Syntax
|
| ContinueStatement :
| continue ;
| continue [no LineTerminator here] Identifier;
|
| […]
| 12.12 Labelled Statements
|
| Syntax
|
| LabelledStatement :
| Identifier : Statement
`skipPoint' is an /Identifier/ and – through Automatic Semicolon Insertion
(ASI) – an /EmptyStatement/ is a /Statement/. One could try placing the
/ExpressionStatement/ – alert(…) – at the same line as the label, but that
should not be necessary in a conforming implementation (which implementation
has been tested with?).
That said, it is certainly not a good idea to "simulate the goto statement".
Please do not post attribution novels: <http://insideoe.com/>
PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Simulate goto Archos <raul.san@sent.com> - 2011-12-27 01:19 -0800
Re: Simulate goto Archos <raul.san@sent.com> - 2011-12-27 01:50 -0800
Re: Simulate goto Archos <raul.san@sent.com> - 2011-12-27 02:09 -0800
Re: Simulate goto Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-12-27 11:31 +0100
Re: Simulate goto "Tom de Neef" <tdeneef@qolor.nl> - 2011-12-27 12:12 +0100
Re: Simulate goto Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-27 18:27 +0100
Re: Simulate goto John G Harris <john@nospam.demon.co.uk> - 2011-12-28 16:56 +0000
Re: Simulate goto Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-28 19:10 +0100
Re: Simulate goto Jake Jarvis <pig_in_shoes@yahoo.com> - 2011-12-28 23:18 +0100
Re: Simulate goto Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-29 12:18 +0100
Re: Simulate goto John G Harris <john@nospam.demon.co.uk> - 2011-12-29 16:31 +0000
Re: Simulate goto Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-29 17:47 +0100
Re: Simulate goto John G Harris <john@nospam.demon.co.uk> - 2011-12-30 11:04 +0000
Re: Simulate goto Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-30 16:10 +0100
Re: Simulate goto John G Harris <john@nospam.demon.co.uk> - 2011-12-27 14:41 +0000
Re: Simulate goto Denis McMahon <denismfmcmahon@gmail.com> - 2011-12-27 15:32 +0000
Re: Simulate goto Gene Wirchenko <genew@ocis.net> - 2011-12-27 10:12 -0800
Re: Simulate goto "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-12-27 19:55 +0000
Re: Simulate goto Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2011-12-27 21:49 +0100
Re: Simulate goto Denis McMahon <denismfmcmahon@gmail.com> - 2011-12-27 23:07 +0000
Re: Simulate goto John G Harris <john@nospam.demon.co.uk> - 2011-12-28 16:28 +0000
Re: Simulate goto Nomen Nescio <nobody@dizum.com> - 2011-12-28 22:33 +0100
Re: Simulate goto Gene Wirchenko <genew@ocis.net> - 2011-12-27 13:19 -0800
Re: Simulate goto "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-12-27 22:02 +0000
Re: Simulate goto Tim Streater <timstreater@greenbee.net> - 2011-12-27 22:18 +0000
Re: Simulate goto Mike Duffy <Use_guestbook_page@website.in.sig> - 2011-12-28 00:23 +0000
Re: Simulate goto John G Harris <john@nospam.demon.co.uk> - 2011-12-28 16:37 +0000
Re: Simulate goto Tim Streater <timstreater@greenbee.net> - 2011-12-28 17:44 +0000
Re: Simulate goto Mike Duffy <Use_guestbook_page@website.in.sig> - 2011-12-29 01:16 +0000
Re: Simulate goto Gene Wirchenko <genew@ocis.net> - 2011-12-28 17:34 -0800
Re: Simulate goto "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-12-29 08:27 +0000
Re: Simulate goto Dr J R Stockton <reply1152@merlyn.demon.co.uk> - 2011-12-30 20:54 +0000
Re: Simulate goto Tim Streater <timstreater@greenbee.net> - 2011-12-31 11:55 +0000
Re: Simulate goto Gene Wirchenko <genew@ocis.net> - 2011-12-27 14:50 -0800
csiph-web