Throught the ECMAScript specification (ECMA-262 - 9th Edition) I've noticed that in many places the term "clause" is used instead of "statement". More specifically the following keywords are referred to as clauses: catch
, extends
, case
, default
and import
. To be more accurate, the last three keywords are only referred to as clauses within abstact operations, never in the actual text.
Here are some examples:
It may be used as the value of an extends clause of a class definition.
(p. 447, ch. 19.1.1 The Object Constructor)
CaseBlock [Yield, Await, Return] :
{ CaseClauses [?Yield, ?Await, ?Return] opt }
{ CaseClauses [?Yield, ?Await, ?Return] opt DefaultClause [?Yield, ?Await, ?Return]
CaseClauses [?Yield, ?Await, ?Return] opt }
(p. 331, ch. 13.12 The switch Statement)
Usually a Lexical Environment is associated with some specific syntactic structure of ECMAScript code such as a FunctionDeclaration, a BlockStatement, or a Catch clause of a TryStatement...
(p. 128, ch. 8.1 Lexical Environments)
ImportDeclaration :
import ImportClause FromClause ;
import ModuleSpecifier ;
(p. 418, ch. 15.2.2 Imports)
I understand that import
is technically a declaration statement (still a statement though) but what about the others? Why are catch
, case
and extends
not referred to as statements?
I understand that
import
is technically a declaration statement (still a statement though) ...
No import
itself is just a keyword. import x from "y";
as a whole is a statement (as it can stand on it's own).
... but what about the others? Why are catch, case and extends not referred to as statements?
Cause they aren't statements on it's own. They don't represent a single action, instead they are part of something bigger. catch
is useless without a try
, extends
is useless without a class
, case
is useless without a switch
.