Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is extended mode?

I'm toying with let in Node v0.10.12. Using the --harmony flag the following code produces a syntax error:

for (let i = 0; i < 2; i += 1) {     console.log('i', i); } 

SyntaxError: Illegal let declaration outside extended mode

However, if I also use the --use-strict flag, then the code runs as expected.

Why is a syntax error thrown when just using the --harmony flag? What is extended mode? What is the connection with strict mode?

like image 376
Randomblue Avatar asked Jun 22 '13 17:06

Randomblue


People also ask

What does extend screen mean?

Extend – makes all of your monitors act like one big monitor extending the desktop across all of them. Duplicate – makes all of the monitors display the same thing duplicating the desktop on each monitor. Projector only – Displays only on the secondary monitor like a projector.

How does extended desktop work?

The Extend option extends your desktop onto an additional monitor, while the other options are mainly useful if you're using an additional monitor for presentations. For example, you could mirror your laptop's desktop onto a large monitor or blank your laptop's screen while it's connected to a larger display.

What is extend screen in Windows 10?

In Extend Mode the external display is treated as a separate screen so that you can have a different windows open on the projector and desktop. It is easy to switch between the two settings.


1 Answers

It looks like "extended mode" was removed from the current development version of the harmony spec on February 27, 2012, but there's a description of what it was supposed to be in a few older ones (this one is from January 16, 2012):

10.1.2 Extended Code

Extended code is any code contained in an ECMAScript Program syntactic unit that contains occurrences of lexical or syntactic productions defined subsequent to the Fifth Edition of the ECMAScript specification. Code is interpreted as extended code in the following situations:

  • Global code is extended global code if it is contained in an ECMAScript Program syntactic unit that has been designated as an extended Program unit in an implementation defined manner or if ???.

  • Eval code is extended eval code if the call to eval is a direct call (see 15.1.2.1.1) to the eval function that is contained in extended mode code or if it begins with ???.

  • Function code that is part of a FunctionDeclaration, FunctionExpression, or accessor PropertyAssignment is extended function code if its FunctionDeclaration, FunctionExpression, or PropertyAssignment is contained in extended mode code or if the function code begins with ???.

  • Function code that is supplied as the last argument to the built-in Function constructor is strict function code if the last argument is a String that when processed as a FunctionBody begins with ???.

The term “strict code” is used to designate both actual strict mode code and extended code while the term “extended code” only designates actual extended code. The term “base code” is used to designate code that is not extended code.

As for the connection with strict mode, that seems to be specific to V8's (experimental) implementation. Here's what the changelog for revision 10062, which introduced the --harmony flag, says:

This CL introduces a third mode next to the non-strict (henceforth called 'classic mode') and 'strict mode' which is called 'extended mode' as in the current ES.next specification drafts. The extended mode is based on the 'strict mode' and adds new functionality to it. This means that most of the semantics of these two modes coincide.

The 'extended mode' is entered instead of the 'strict mode' during parsing when using the 'strict mode' directive "use strict" and when the the harmony-scoping flag is active. This should be changed once it is fully specified how the 'extended mode' is entered.

like image 189
Blender Avatar answered Sep 28 '22 08:09

Blender