Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26339 > unrolled thread

Optional semicolons - wrong rule or wrong example?

Started byPeter <pilarp@poczta.onet.pl>
First post2014-12-16 13:58 -0800
Last post2014-12-18 14:04 +0000
Articles 3 on this page of 23 — 8 participants

Back to article view | Back to comp.lang.javascript


Contents

  Optional semicolons - wrong rule or wrong example? Peter <pilarp@poczta.onet.pl> - 2014-12-16 13:58 -0800
    Re: Optional semicolons - wrong rule or wrong example? "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-16 23:21 +0100
    Re: Optional semicolons - wrong rule or wrong example? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-12-17 00:10 +0100
      JavaScript: The Definitive Guide (was: Optional semicolons - wrong rule or wrong example?) "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-17 01:29 +0100
        Re: JavaScript: The Definitive Guide Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-12-20 23:00 +0100
          Re: JavaScript: The Definitive Guide Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-12-20 23:04 +0100
          Re: JavaScript: The Definitive Guide "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-12-28 23:52 +0100
            Re: JavaScript: The Definitive Guide Tim Streater <timstreater@greenbee.net> - 2014-12-28 23:52 +0000
              Re: JavaScript: The Definitive Guide Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-01 21:46 -0800
                Re: JavaScript: The Definitive Guide "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-02 09:32 +0100
                  Re: JavaScript: The Definitive Guide Andrew Poulos <ap_prog@hotmail.com> - 2015-01-03 07:54 +1100
                    Re: JavaScript: The Definitive Guide "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-02 22:14 +0100
                      Re: JavaScript: The Definitive Guide Andrew Poulos <ap_prog@hotmail.com> - 2015-01-03 11:46 +1100
                        Re: JavaScript: The Definitive Guide "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-03 11:59 +0100
                          Re: JavaScript: The Definitive Guide Andrew Poulos <ap_prog@hotmail.com> - 2015-01-03 23:46 +1100
                            Re: JavaScript: The Definitive Guide "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-03 14:57 +0100
                              Re: JavaScript: The Definitive Guide Andrew Poulos <ap_prog@hotmail.com> - 2015-01-04 09:31 +1100
                                Re: JavaScript: The Definitive Guide "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-04 00:29 +0100
                                  Re: JavaScript: The Definitive Guide Andrew Poulos <ap_prog@hotmail.com> - 2015-01-04 20:17 +1100
                                    Re: JavaScript: The Definitive Guide "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-04 10:57 +0100
                      OT: Mass, weight and friction (was: JavaScript: The Definitive Guide) "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-03 02:52 +0100
    Re: Optional semicolons - wrong rule or wrong example? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2014-12-18 14:39 +0100
      Re: Optional semicolons - wrong rule or wrong example? Tim Streater <timstreater@greenbee.net> - 2014-12-18 14:04 +0000

Page 2 of 2 — ← Prev page 1 [2]


#26443 — OT: Mass, weight and friction (was: JavaScript: The Definitive Guide)

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2015-01-03 02:52 +0100
SubjectOT: Mass, weight and friction (was: JavaScript: The Definitive Guide)
Message-ID<m87hvv$iuf$1@solani.org>
In reply to#26439
Evertjan. wrote:

> Andrew Poulos <ap_prog@hotmail.com> wrote on 02 jan 2015 in 
> comp.lang.javascript:
> 
>> Cool, so a pound of feathers *does* weigh more than a pound of gold! 
> 
> Mass is what stuff has, "avoir du pois" in French, 
> weight is its pressure against the ground.
> 
> So no, it weighs less, 
> as the feathers with the same mass as the gold have more volume,
> and so their upward pressure by the surrounding air has more effect.

I strongly suggest to discuss these issues in a newsgroup where are on
topic, because somebody with a sound knowledge of physics and concern
for the topic might care to solve this confusion.

[F'up2 sci.physics]

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#26360

FromErwin Moller <erwinmollerusenet@xs4all.nl>
Date2014-12-18 14:39 +0100
Message-ID<5492d90d$0$2851$e4fe514c@news2.news.xs4all.nl>
In reply to#26339
On 12/16/2014 10:58 PM, Peter wrote:
> In the 6th edition of "JavaScript: The Definitive Guide",
> in chapter 2.5 (Optional Semicolons), the following rule
> can be found:
>
> "JavaScript treats a line break as a semicolon if the next
> nonspace character cannot be interpreted as a continuation of
> the current statement".
>
> and the following example is given:
>
> var a
> a
> =
> 3
> console.log(a)
>
> According to the author, the above shall be treated as:
>
> var a; a = 3; console.log(a);
>
> He justifies it as follows:
>
> "JavaScript does treat the first line break as a semicolon because it cannot parse the code var a a without a semicolon."
>

My advice:
When things are confusing, strive to make them clear.
Don't rely on (poorly understood) rules to solve the problem.
Simply avoid the problem.

In this case: Simply stick to using a semicolon, even if you are allowed 
to omit it.


This case reminds me of order of operations: (multiply, power, addition, 
division, modulo, etc)
http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages

I don't know that list by heart, so I use parenthesis a lot to make the 
order clear.

Regards,
Erwin Moller

-- 
"That which can be asserted without evidence, can be dismissed without 
evidence."
-- Christopher Hitchens

[toc] | [prev] | [next] | [standalone]


#26361

FromTim Streater <timstreater@greenbee.net>
Date2014-12-18 14:04 +0000
Message-ID<181220141404027857%timstreater@greenbee.net>
In reply to#26360
In article <5492d90d$0$2851$e4fe514c@news2.news.xs4all.nl>, Erwin
Moller <erwinmollerusenet@xs4all.nl> wrote:

>My advice:
>When things are confusing, strive to make them clear.
>Don't rely on (poorly understood) rules to solve the problem.
>Simply avoid the problem.
>
>In this case: Simply stick to using a semicolon, even if you are allowed 
>to omit it.
>
>This case reminds me of order of operations: (multiply, power, addition, 
>division, modulo, etc)
>http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages
>
>I don't know that list by heart, so I use parenthesis a lot to make the 
>order clear.

This is very good advice.

-- 
"If you're not able to ask questions and deal with the answers without feeling 
that someone has called your intelligence or competence into question, don't 
ask questions on Usenet where the answers won't be carefully tailored to avoid
tripping your hair-trigger insecurities."                  - D M Procida, UCSM

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.javascript


csiph-web