Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #16606
| Message-ID | <1877322.0HhiMAB5S9@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2012-10-13 21:55 +0200 |
| Subject | Re: What's a good Javascript book? |
| Newsgroups | comp.lang.javascript |
| References | (8 earlier) <a1948f28-2c8b-4a73-b5bc-eba32170b5dd@z8g2000yql.googlegroups.com> <r6zRnbECT+dQFwVq@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> <OMqdnWmmf4367eXNnZ2dnUVZ_jadnZ2d@earthlink.com> <OBVQQeDRlTeQFwbb@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> <X-idnWKz4_YlK-TNnZ2dnUVZ_hadnZ2d@earthlink.com> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
Patricia Shanahan wrote:
> John G Harris wrote:
>> Patricia Shanahan wrote:
>> <snip>
>>> According to the grammar in
>>> http://www.ecma-international.org/ecma-262/5.1/, Statement can be
>>> expanded to Block, so some blocks are statements. On the other hand,
>>> there are contexts which require Block rather than Statement, for
>>> example in a TryStatement. A block that appears where a statement is not
>>> permitted cannot be a statement.
>> <snip>
>>
>> I don't agree with your reasoning there. The standard says 'try' must be
>> followed by a block statement. If it said that 'try' must be followed by
>
> Could you give me a reference for where you are getting the phrase
> "block statement"?
>
> I've searched both http://www.ecma-international.org/ecma-262/5.1/ and a
> recently downloaded copy of
> http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf,
> and without finding the phrase. Maybe there is some other document I
> should be consulting. If so, please give me a pointer.
Section "12.1 Block" of the ECMAScript Language Specification, 5.1 Edition
(and all previous Editions; section numbering may differ) is a subsection of
section "12 Statements". That, the productions for the /Statement/ goal
symbol defined in the latter section –
| Statement :
| Block
| VariableStatement
| EmptyStatement
| ExpressionStatement
| IfStatement
| IterationStatement
| ContinueStatement
| BreakStatement
| ReturnStatement
| WithStatement
| LabelledStatement
| SwitchStatement
| ThrowStatement
| TryStatement
| DebuggerStatement
(previous Editions contain the productions starting from LabelledStatement
to a varying degree) –, and that an ECMAScript program is produced from
| 14 Program
|
| Syntax
|
| Program :
| SourceElements_opt
|
| SourceElements :
| SourceElement
| SourceElements SourceElement
|
| SourceElement :
| Statement
| FunctionDeclaration
specify that what can be produced from the Block goal symbol is considered a
statement, or, IOW, that there is a Block statement. This may be
colloquially written "block statement".
The syntax for "12.14 The try Statement" (which *also* is a subsection of
section 12) is:
| TryStatement :
| try Block Catch
| try Block Finally
| try Block Catch Finally
|
| Catch :
| catch ( Identifier ) Block
|
| Finally :
| finally Block
This means that the `try' keyword must be followed by a statement,
specifically a Block statement.
That there is a Block statement and a LabelledStatement in ECMAScript is one
reason why
return
{
foo: "bar"
};
produces unexpected results as it is equivalent to
return;
{
foo: "bar";
};
where the `undefined' value is returned and `foo' is considered a label for
the "bar" ExpressionStatement. Which has been correctly observed by
Crockford, among others.
[His conclusion from that, that Allman style is inappropriate on the whole
in ECMAScript implementations is premature and fallacious, though. For it
is exactly the ambiguity between Block statements and Object initializers,
and Function declarations and Function expressions that makes it a good idea
to format them differently:
if (foo)
{
bar();
}
but
return {
foo: "bar"
};
and
function foo (bar)
{
baz();
}
but
var foo = function (bar) {
baz();
};
and, by extension,
var foo = (function (baz) {
return function bar (foobar) {
return foobar(bar, baz);
};
}(42));
]
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What's a good Javascript book? I Am Here <iamhereintheworld@gmail.com> - 2012-10-08 06:35 -0700
Re: What's a good Javascript book? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-10-08 13:52 +0000
Re: What's a good Javascript book? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-10-08 17:03 +0300
Re: What's a good Javascript book? Tim Streater <timstreater@greenbee.net> - 2012-10-08 15:22 +0100
Re: What's a good Javascript book? "Mel Smith" <med_cutout_syntel@aol.com> - 2012-10-08 08:56 -0600
Re: What's a good Javascript book? Stefan Weiss <krewecherl@gmail.com> - 2012-10-08 16:11 +0200
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-09 10:43 +0100
Re: What's a good Javascript book? Stefan Weiss <krewecherl@gmail.com> - 2012-10-09 13:12 +0200
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-10 15:32 +0100
Re: What's a good Javascript book? Stefan Weiss <krewecherl@gmail.com> - 2012-10-10 20:13 +0200
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-11 14:28 +0100
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-09 17:56 +0100
Re: What's a good Javascript book? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-10 00:32 +0200
Re: What's a good Javascript book? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-10-09 16:37 -0700
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-10 06:44 +0100
Re: What's a good Javascript book? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-10 20:09 +0200
Re: What's a good Javascript book? Dr J R Stockton <reply1241@merlyn.demon.co.uk.invalid> - 2012-10-11 19:43 +0100
Re: What's a good Javascript book? Gregor Kofler <usenet@gregorkofler.com> - 2012-10-08 16:21 +0200
Re: What's a good Javascript book? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-10-08 07:56 -0700
Re: What's a good [JavaScript] book? Matt McDonald <matt@fortybelow.ca> - 2012-10-08 11:38 -0400
Re: What's a good [JavaScript] book? Matt McDonald <matt@fortybelow.ca> - 2012-10-08 11:42 -0400
Re: What's a good [JavaScript] book? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-10 00:41 +0200
Re: What's a good Javascript book? Danny <dann90038@gmail.com> - 2012-10-08 11:57 -0700
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-08 20:39 +0100
Re: What's a good Javascript book? I Am Here <iamhereintheworld@gmail.com> - 2012-10-09 06:19 -0700
Re: What's a good Javascript book? Gregor Kofler <usenet@gregorkofler.com> - 2012-10-09 18:43 +0200
Re: What's a good Javascript book? Gene Wirchenko <genew@ocis.net> - 2012-10-09 10:06 -0700
Re: What's a good Javascript book? Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-09 11:43 -0700
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-09 20:07 +0100
Re: What's a good Javascript book? Gene Wirchenko <genew@ocis.net> - 2012-10-09 13:40 -0700
Re: What's a good Javascript book? Gregor Kofler <usenet@gregorkofler.com> - 2012-10-09 20:55 +0200
Re: What's a good Javascript book? Gene Wirchenko <genew@ocis.net> - 2012-10-09 13:45 -0700
Re: What's a good Javascript book? Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-10 04:31 -0700
Re: What's a good Javascript book? Stefan Weiss <krewecherl@gmail.com> - 2012-10-09 20:09 +0200
Re: What's a good Javascript book? Gregor Kofler <usenet@gregorkofler.com> - 2012-10-09 21:01 +0200
Re: What's a good Javascript book? Gene Wirchenko <genew@ocis.net> - 2012-10-09 13:50 -0700
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-10 15:26 +0100
Re: What's a good Javascript book? Tim Streater <timstreater@greenbee.net> - 2012-10-10 15:58 +0100
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-11 14:39 +0100
Re: What's a good Javascript book? Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-11 06:52 -0700
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-11 17:13 +0100
Re: What's a good Javascript book? Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-11 10:39 -0700
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-12 10:37 +0100
Re: What's a good Javascript book? Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-12 07:11 -0700
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-13 10:53 +0100
Re: What's a good Javascript book? Gene Wirchenko <genew@ocis.net> - 2012-10-12 09:49 -0700
Re: What's a good Javascript book? Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-12 10:22 -0700
Re: What's a good Javascript book? Gene Wirchenko <genew@ocis.net> - 2012-10-12 13:17 -0700
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-12 20:32 +0100
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-13 10:50 +0100
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-13 19:45 +0100
Re: What's a good Javascript book? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-13 21:55 +0200
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-13 21:52 +0100
Re: What's a good Javascript book? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-13 23:49 +0200
Re: What's a good Javascript book? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-13 23:57 +0200
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-13 23:34 +0100
Re: What's a good Javascript book? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-14 02:09 +0200
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-14 00:00 +0100
Re: What's a good Javascript book? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-14 01:58 +0200
Re: What's a good Javascript book? Patricia Shanahan <pats@acm.org> - 2012-10-14 07:17 +0100
Re: What's a good Javascript book? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-15 01:17 +0200
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-14 13:40 +0100
Re: What's a good Javascript book? Gene Wirchenko <genew@ocis.net> - 2012-10-14 19:03 -0700
Re: What's a good Javascript book? John G Harris <john@nospam.demon.co.uk> - 2012-10-15 10:42 +0100
Re: What's a good Javascript book? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-10-09 22:49 +0200
Re: What's a good Javascript book? Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-09 12:00 -0700
Re: What's a good Javascript book? I Am Here <iamhereintheworld@gmail.com> - 2012-10-16 06:57 -0700
csiph-web