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


Groups > comp.lang.javascript > #33462

Re: x === x

Path csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: x === x
Date Thu, 01 Jun 2017 01:46:03 +0100
Organization A noiseless patient Spider
Lines 42
Message-ID <87k24wy1pw.fsf@bsb.me.uk> (permalink)
References <JavaScript-20170530123255@ram.dialup.fu-berlin.de> <874lw231ui.fsf@bsb.me.uk> <context-20170530144535@ram.dialup.fu-berlin.de> <2872662.aeNJFYEL58@PointedEars.de> <87inkh28sf.fsf@bsb.me.uk> <19437984.EfDdHjke4D@PointedEars.de> <87efv4zr3k.fsf@bsb.me.uk> <2276977.Lt9SDvczpP@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
Injection-Info mx02.eternal-september.org; posting-host="b8cfcc8b3b6248419b3e2a0831823cf6"; logging-data="25362"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YkYB5OimERIEulotcPMjB/1Ogkmqk8Iw="
Cancel-Lock sha1:kaf7+HBVxj3Fd4NfZcP6VFQNUfw= sha1:9bcAHrr1b+fghR9AbiRKi/EyOSI=
X-BSB-Auth 1.f6c04c2de75ba01d065f.20170601014603BST.87k24wy1pw.fsf@bsb.me.uk
Xref csiph.com comp.lang.javascript:33462

Show key headers only | View raw


Thomas 'PointedEars' Lahn <PointedEars@web.de> writes:

> Ben Bacarisse wrote:
>
>> Thomas 'PointedEars' Lahn <PointedEars@web.de> writes:
>>> | > {} === {}
>>> | <- false
>>> | {} === {};
>>> | (x) Uncaught SyntaxError: Unexpected token ===
>>>
>>> I assume that the explicit semicolon there is considered an
>>> /EmptyStatement/ that switches back to statement context.
>> 
>> I can't find any reference to "statement context" or "expression
>> context" in the language standard.  I assume it's your own terminology,
>> but I don't see how it helps explain why [] === []; is OK but {} === {};
>> is a syntax error.  (I know why, I'm just wondering how talking about
>> === making expression context and ; switching back helps to explain this
>> difference.)
>
> Simply put, ECMAScript syntax is ambiguous, and it depends on the context 
> how it is parsed.  For example, “{}” can be parsed either as an empty 
> /Block/ *statement* (which can only be produced by the /Statement/ 
> production) or as an empty Object initializer; the latter is an *expression* 
> (it can only be produced by the /Expression/ production).  A further 
> complication is the /ExpressionStatement/ production (IIRC).

I am reasonably sure that ECMAScript syntax is not ambiguous (at least
on this matter).  Can you cite the parts of the syntax that leads to it
being ambiguous?  Alternatively, can you give an ECMAScript script which
is ambiguous?  The grammar is gruesome, so maybe they committee did slip
up.

> I will consider the rest of your posting later.

This part of my post was about what you mean by "=== *makes* the
(expression) context" and what "switches back to statement context"
means (or, more specifically, how those phrases help explain what's
going on).

-- 
Ben.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-30 14:34 +0100
  Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-30 15:02 +0100
  Re: x === x Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-30 16:22 +0200
    Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-31 01:02 +0100
      Re: x === x Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-31 12:39 +0200
        Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-31 21:52 +0100
          Re: x === x Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-31 23:39 +0200
            Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-01 01:46 +0100
              Re: x === x Julio Di Egidio <julio@diegidio.name> - 2017-06-01 00:14 -0700
                Re: x === x John G Harris <niam@jghnorth.org.uk.invalid> - 2017-06-01 10:39 +0100
                Re: x === x Julio Di Egidio <julio@diegidio.name> - 2017-06-01 03:37 -0700
                Re: x === x John G Harris <niam@jghnorth.org.uk.invalid> - 2017-06-01 18:54 +0100
                Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-01 21:54 +0100
                Re: x === x John G Harris <niam@jghnorth.org.uk.invalid> - 2017-06-02 11:06 +0100
                Re: x === x John G Harris <niam@jghnorth.org.uk.invalid> - 2017-06-02 11:08 +0100
                Re: x === x John G Harris <niam@jghnorth.org.uk.invalid> - 2017-06-02 10:56 +0100
                Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-04 12:50 +0100
                Re: x === x John G Harris <niam@jghnorth.org.uk.invalid> - 2017-06-04 14:30 +0100
                Re: x === x Dr J R Stockton <J.R.Stockton@physics.org> - 2017-06-04 09:03 -0700
                Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-01 14:45 +0100
                Re: x === x Julio Di Egidio <julio@diegidio.name> - 2017-06-01 07:00 -0700
        Re: x === x Julio Di Egidio <julio@diegidio.name> - 2017-06-01 00:00 -0700

csiph-web